Building Dynamic Controls

Discussion in 'ASP .Net Building Controls' started by Robert Bevington, Jul 11, 2007.

  1. Hi everyone,
    Can anyone point me in the right direction on this one?

    I have a page with a GridView whose column names vary. On Page Load I
    search for specific columns (they can be identified by a prefix in the
    column name) and then want to create one or more drop-down list boxes
    depending on the number of columns. Each drop-down list box is to be
    associated to a column. The number and names of the columns is not fixed.

    What's the best approach for dealing with this?

    I'm trying a For Next Loop at the moment but cannot get the dynamic bits
    working. I get three drop-down lists.

    <%-- Start Dynamic attribute field creation--%>

    <% For attCount = 1 To ATT_Columns.Count
    Dim ATT_Name As String = ATT_Columns(attCount)
    %>

    <asp:DropDownList ID="cboDept" runat="server"
    DataSourceID="SqlDataSource1" DataTextField="ATT_Department"
    DataValueField="ATT_Department" AppendDataBoundItems="True">

    <asp:ListItem>Select from list</asp:ListItem>
    </asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:Search4TextConnectionString %>"

    SelectCommand="SELECT DISTINCT [ATT_Department] FROM NewTM2 ORDER BY
    ATT_Department"></asp:SqlDataSource>
    <% Next
    %>

    How can I replace, for example, ATT_Department with the variable ATT_Name

    Any help would be great.

    Thanks

    Rob
    Robert Bevington, Jul 11, 2007
    #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. =?Utf-8?B?SXJmYW4gQWtyYW0=?=

    Dynamic Controls in asp.net...Building a tree hierarchy..please he

    =?Utf-8?B?SXJmYW4gQWtyYW0=?=, Dec 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    488
    =?Utf-8?B?SXJmYW4gQWtyYW0=?=
    Dec 13, 2004
  2. =?Utf-8?B?c2NvdHRybQ==?=

    building dynamic list of web from controls

    =?Utf-8?B?c2NvdHRybQ==?=, Apr 18, 2005, in forum: ASP .Net
    Replies:
    12
    Views:
    649
    Steven Cheng[MSFT]
    Apr 28, 2005
  3. Ronald
    Replies:
    2
    Views:
    819
    Robbe Morris [C# MVP]
    Jan 17, 2006
  4. Denny Smolinski via .NET 247

    Dynamic Controls, Placeholder, Retrieve Information from Dynamic Controls

    Denny Smolinski via .NET 247, May 4, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    453
    Eidolon
    May 4, 2004
  5. Irfan Akram
    Replies:
    1
    Views:
    149
    Mujtaba Syed
    Dec 13, 2004
Loading...

Share This Page