Dynamic temp. datagrid col.gen. -Session access inside a class inside a UserCtrl

Discussion in 'ASP .Net Building Controls' started by Andy Eshtry, Mar 1, 2004.

  1. Andy Eshtry

    Andy Eshtry Guest

    Hello Dear Professionals:
    Based on this document:
    http://msdn.microsoft.com/library/d...atingwebservercontroltemplatesdynamically.asp
    or this http://www.dnzone.com/ShowDetail.asp?NewsId=599
    I want to create 3 template column in datagrid dynamically while the
    template columns
    contains image buttons for add, edit and delete. As you can see, I can
    figure out the commandname inside the imageButton_Command event but I do not
    know how can store info in session object and also use response.redirect
    inside that event cause it is in the DataGridTemplate Class not the upper
    user control which contains that class. Also access other datagrid columns'
    data like id of current datagrid row.
    Thank you very much for your kind attention.
    Best Wishes
    Andy Eshtry



    public class DataGridTemplate : System.Web.UI.ITemplate
    {
    ListItemType templateType;
    string columnName;

    public DataGridTemplate(ListItemType type, string colname)
    {
    templateType = type;
    columnName = colname;
    }

    public void InstantiateIn(System.Web.UI.Control container)
    {
    Literal lc = new Literal();
    switch(templateType)
    {
    case ListItemType.Header:
    lc.Text = "<B>" + columnName + "</B>";
    container.Controls.Add(lc);
    break;
    case ListItemType.Item:
    ImageButton imageButton = new ImageButton();
    imageButton.ImageUrl = "../Images/view.png";
    imageButton.AlternateText = columnName;
    imageButton.Command += new CommandEventHandler(imageButton_Command);
    imageButton.CommandName = "View";
    container.Controls.Add(imageButton);
    break;
    }
    }

    void imageButton_Command(object sender, CommandEventArgs e)
    {
    if (e.CommandName == "View")
    {
    //can not use session or response.redirect or how can I sent commandname up
    to container user control or access other datagrid columns's data
    }
    }
     
    Andy Eshtry, Mar 1, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Eshtry
    Replies:
    0
    Views:
    645
    Andy Eshtry
    Mar 1, 2004
  2. Replies:
    2
    Views:
    593
    Mark P
    May 9, 2005
  3. Andy Eshtry
    Replies:
    0
    Views:
    185
    Andy Eshtry
    Mar 1, 2004
  4. Andy Eshtry
    Replies:
    0
    Views:
    169
    Andy Eshtry
    Mar 1, 2004
  5. Replies:
    8
    Views:
    235
    Eric Sosman
    Apr 20, 2013
Loading...

Share This Page