dynamically generate listcheckbox in a table based on another check box list

Discussion in 'ASP .Net' started by KBuser, Apr 10, 2006.

  1. KBuser

    KBuser Guest

    I'm building an internal site which will allow for extremely
    customizable queries to be run against our SQL Server (2000) DB. The
    page is done in ASP .net 2.0, with C# code behind.
    The initial page has a checkboxlist which is generated from a query
    which returns all the user tables in our database. This is
    checkboxlistTables. For each table selected in this list I want to
    dynamically generate a new checkboxlist in a (HTML) table on the page.
    These new check lists query the database and display a checkbox for
    each column in the associated table.

    The way I'm doing it now is, I've simply created the 12 or 13
    checkboxlists (one for each table in our db) which query
    INFORMATION_SCHEMA.Columns to populate their lists. I simply make these
    listboxes visible when the appropriate check box is checked in
    checkboxlistTables. As you can imagine this entails a lot of redundant
    code, and will 'cause some problems down the road as tables are
    added/deleted. What I want to do is create an array (or something
    similar) of checkboxlists, which are generated and populated on the fly
    as needed. This is where I am stuck, as I've never done something like
    this, and am not sure how to proceed.

    At the moment I use something along the lines of:
    for (int i = 0; i < CheckBoxList0.Items.Count; i++)

    for each checkboxlist (CheckBoxList0 - CheckBoxList11) to see which
    columns from which tables needed to be included in my query. I'd like
    to be able to do something like:
    for (int i = 0; i < CheckBoxList[x].Items.Count;i++) inside of a larger
    loop which cycles through all of the generated listboxes. Is this
    possible? Any solutions/suggestions on generating these listboxes and
    cycling through them?

    Thanks in advance,
    KrB
     
    KBuser, Apr 10, 2006
    #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. mit
    Replies:
    1
    Views:
    815
    Ramu Pulipati
    Jan 25, 2006
  2. Leonardo Gangemi
    Replies:
    0
    Views:
    318
    Leonardo Gangemi
    Apr 7, 2004
  3. Replies:
    1
    Views:
    1,152
    David Wier
    Aug 5, 2005
  4. dthmtlgod

    Fill Combo Box based on another Combo Box

    dthmtlgod, Nov 16, 2005, in forum: ASP General
    Replies:
    1
    Views:
    594
    Bob Barrows [MVP]
    Nov 16, 2005
  5. babu17
    Replies:
    1
    Views:
    139
Loading...

Share This Page