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

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

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

    Hello Dear Professionals:
    Based on this document:
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingwebservercontroltemplatesdynamically. asp[/url]
    or this [url]http://www.dnzone.com/ShowDetail.asp?NewsId=599[/url]
    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
    [email]andyeshtry@hotmail.com[/email]


    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 Guest

  2. Similar Questions and Discussions

    1. How can I access a component inside a class file?
      If I set up a component in Main.mxml e.g. <mx:Text id="stxt" text="" width="240" height="650"/> How can I set the text in an imported class...
    2. can i use dynamic variable inside a dataadapter and bind to datagrid
      Hi I want to use a sql designed in the dataadapter and I want to pass a variable so it can retrieve related data by using "WHERE" clause in the...
    3. How to access the controls that are inside of a DataList/DataGrid using JS?
      My problem is simple, i have a datalist control with some controls inside of EditTemplate (the problem is the same in the DataGrid). I want to have...
    4. Using class inside ASP
      Hi all professional I would like to know how to using java class file inside ASP page I have placed the class file to C:\WINNT\java\trustlib...
    5. #23038 [Com]: PHP does not detect parent class inside child class' constructor
      ID: 23038 Comment by: hewei at ied dot org dot cn Reported By: black at sunshine dot krneki dot org Status: ...
  3. #2

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

    Hello Dear Professionals:
    Based on this document:
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingwebservercontroltemplatesdynamically. asp[/url]
    or this [url]http://www.dnzone.com/ShowDetail.asp?NewsId=599[/url]
    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
    [email]andyeshtry@hotmail.com[/email]


    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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139