Dynamic control creation in datagrid based on data in that column

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Dynamic control creation in datagrid based on data in that column

    I am creating a dynamic datagrid. The controls in some of the template
    columns will have to be generated based on the data contained in them
    (i.e. the data for that respective DataField column). For example, if I

    have a column called Available, the possible values for it are Yes or
    No. In case it is "Yes" I need a label in that column and in case it is

    "No" I need a hyperlink. Pls help.

    mitramay@gmail.com Guest

  2. Similar Questions and Discussions

    1. Dynamic Template column in DataGrid control
      Hi Everybody, I am trying to create a dynamic template column in a datagri control using the ITemplate interface. //part of my code in the...
    2. Move bound column to right of dynamic column in datagrid?
      I have a datatable that I am binding to a C# ASP.NET 1.1 web page. I also want to put an "Edit" column on the datagrid. However, whenever I use...
    3. Dynamic Control Creation with Reflection?
      I have a DataTable with String-typed columns that looks like this: "TextBox" "txtTest" "Enter Here" Strictly programmtically in my...
    4. Dynamic Template Column Sorting in DataGrid control
      Hi, am facing a problem while using ASP.NET Datagrid Template Columns generated dynamically. Scenario: ------------- 1) I have a custom...
    5. Dynamic Control Creation w/Events?
      I have an ASP.NET web page in which consists of one panel object named pnlTest. In the Page_Load event I'm adding buttons dynamically like so: ...
  3. #2

    Default Re: Dynamic control creation in datagrid based on data in that column

    > have a column called Available, the possible values for it are Yes or
    > No. In case it is "Yes" I need a label in that column and in case it is
    >
    > "No" I need a hyperlink. Pls help.
    <ItemTemplate>
    <asp:Label ID='lbl' ... />
    <asp:LinkButton ID='lbtn' .../>
    </ItemTemplate>


    dataGrid1.ItemCreated += dataGrid1_ItemCreated;

    void dataGrid1_ItemCreated(...)
    {
    DataGridItem item = e.Item;
    Control labelControl = item.FindControl("lbl");
    Control lbtnControl = item.FindControl("lbtn");

    if(toShowLabel)
    {
    labelControl.Visible = true;
    lbtnControl.Visible = false;
    } else
    {
    labelControl.Visible = false;
    lbtnControl.Visible = true;
    }
    }

    HTH

    --
    Happy Hacking,
    Gaurav Vaish | [url]http://www.mastergaurav.com[/url]
    [url]http://www.edujinionline.com[/url]
    [url]http://articles.edujinionline.com/webservices[/url]
    -------------------


    Gaurav Vaish \(www.EduJiniOnline.com\) 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