Huge number of checkboxes to be populated from database

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

  1. #1

    Default Huge number of checkboxes to be populated from database

    I have a database with 90-odd true-false values that I need to display
    on a webform as checkboxes. There are also some other values (numbers
    and text) that need to be displayed.

    I'm wondering the best way to do this! Do I need to individually
    place and databind 90 checkboxes (and label them!) or is there a
    better way? Note, this is 90 values *per row* of the
    query...ultimately I'd like to be able to page through this data.

    Thanks for any help.

    Lerch



    Mike Lerch Guest

  2. Similar Questions and Discussions

    1. Meta Tags Populated by database
      Hello Im wanting to populate my keywords from my SQL database, its works fine - but im just checking if I am allowed to do this. Ive checked...
    2. Limiting Number of Checkboxes
      I am hoping someone can help with this. I am running a query which selects all members of staff. This is then output to a form with checkboxes...
    3. Updating database through a datagrid using checkboxes
      I need to update items in a database queue, so I am attempting to write a ASP.NET utility to do this instead of the users just typing SQL. I am...
    4. SQL1040N The maximum number of applications is already connected to the database.
      hi, i keep getting this error when i have only one application connect to the remote server (it is db2 udb v8.1 on windows 2003). After i...
    5. Huge number of sent Packets
      I connect to the Internet through a LAN connection at my office. Sometimes, when I check the status of my connection, I find huge numbers of sent...
  3. #2

    Default Re: Huge number of checkboxes to be populated from database

    A solution could be a PlaceHolder control.

    Suppose that you have the result of your query in a DataReader. You
    loop through each field of a row, then you add dynamic checkboxes in
    the PlaceHolder. That way you can set the label and the checked value
    easily within your query.

    Everything is dynamic so you don't have to modify your webform, you
    just modify your query instead. Hope this helps!

    Matt


    On Fri, 01 Aug 2003 18:19:16 -0400, Mike Lerch
    <mlerchNOSPAMTHANKS@nycap.rr.com> wrote:
    >I have a database with 90-odd true-false values that I need to display
    >on a webform as checkboxes. There are also some other values (numbers
    >and text) that need to be displayed.
    >
    >I'm wondering the best way to do this! Do I need to individually
    >place and databind 90 checkboxes (and label them!) or is there a
    >better way? Note, this is 90 values *per row* of the
    >query...ultimately I'd like to be able to page through this data.
    >
    >Thanks for any help.
    >
    >Lerch
    >
    >
    Matt Guest

  4. #3

    Default Re: Huge number of checkboxes to be populated from database


    try with CHECKBOXLIST control, u can bind it dataset...
    this will might help you.

    vrushal
    >-----Original Message-----
    >A solution could be a PlaceHolder control.
    >
    >Suppose that you have the result of your query in a
    DataReader. You
    >loop through each field of a row, then you add dynamic
    checkboxes in
    >the PlaceHolder. That way you can set the label and the
    checked value
    >easily within your query.
    >
    >Everything is dynamic so you don't have to modify your
    webform, you
    >just modify your query instead. Hope this helps!
    >
    >Matt
    >
    >
    >On Fri, 01 Aug 2003 18:19:16 -0400, Mike Lerch
    ><mlerchNOSPAMTHANKS@nycap.rr.com> wrote:
    >
    >>I have a database with 90-odd true-false values that I
    need to display
    >>on a webform as checkboxes. There are also some other
    values (numbers
    >>and text) that need to be displayed.
    >>
    >>I'm wondering the best way to do this! Do I need to
    individually
    >>place and databind 90 checkboxes (and label them!) or is
    there a
    >>better way? Note, this is 90 values *per row* of the
    >>query...ultimately I'd like to be able to page through
    this data.
    >>
    >>Thanks for any help.
    >>
    >>Lerch
    >>
    >>
    >
    >.
    >
    Vrushal Guest

  5. #4

    Default Re: Huge number of checkboxes to be populated from database

    On Sat, 02 Aug 2003 00:51:58 GMT, Matt <metal@rocks.com> wrote:
    >A solution could be a PlaceHolder control.
    >
    >Suppose that you have the result of your query in a DataReader. You
    >loop through each field of a row, then you add dynamic checkboxes in
    >the PlaceHolder. That way you can set the label and the checked value
    >easily within your query.
    >
    >Everything is dynamic so you don't have to modify your webform, you
    >just modify your query instead. Hope this helps!
    Thanks for the tip!

    What I ended up doing was writing a little helper function to generate
    the code for me. We had a table that listed the field name in one
    column and the label (the question that was being checked yes or no)
    in another, so I queried that and generated all the
    <asp:checkbox......></asp:checkbox>, setting their IDs to
    "chkFIELDNAME" and adding 15 to their TOP value. I pasted the output
    of that right into the HTML window of the app, and that was it! I
    just had to arrange them on the form.

    The webform binds all the checkboxes (plus the handful of text boxes)
    using this.databind() in the page load event

    Here's the bulk of the code for the helper function if anyone wants to
    use it!

    string outstring="";
    string colname="";
    foreach(System.Data.DataColumn dc in
    dataSet11.Tables["View2"].Columns)
    {
    toppos+=15;
    colname=dc.ColumnName;
    outstring+="<asp:CheckBox id=chk" + colname + "
    style=\"Z-INDEX: 107; LEFT: 400px; POSITION: absolute; TOP: " +
    toppos.ToString() + "px\" runat=\"server\" Text=\"" + colname + "\"
    Height=\"4px\" Width=\"60px\" Checked='<%# DataBinder.Eval(dataSet11,
    \"Tables[VIEW2].DefaultView.[0]." + colname + "\")
    %>'></asp:CheckBox>\r\n" ;
    }
    Mike Lerch 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