Checkboxes checked in runtime datagrid

Discussion in 'ASP .Net' started by DJ Dev, Feb 8, 2004.

  1. DJ Dev

    DJ Dev Guest

    Hi All,
    I have a complex problem. I have dropdownlists (usually 3-5) and the
    user selects some value from these and for each value selected,
    datagrids are shown to the user. I am creating the Datagrids
    dynamically using a loop depending on the number of Dropdownlists. The
    datagrids also have a checkbox template column. Now my problem is that
    how can I access the values selected by the user from these
    checkboxes. He checks one or more checkboxes for each of the datagrid.
    I am assigning unique ids to datagrids while creation. When the page
    postsback, the datagrid is reconstructed dynamically. Can I use
    viewstate or something to get what the user selected before the
    datagrid is re-built on postback.
    Thanks!
     
    DJ Dev, Feb 8, 2004
    #1
    1. Advertising

  2. If you need to maintain viewstate in dynamically-created controls, you might
    want to look at this free control from Denis Bauer:

    "ASP.NET gives a developer the opportunity to programmatically add controls
    to a web form using ParentControl.Controls.Add(new Control());
    However, these controls are not persisted in any way thus having to be
    recreated for each subsequent request. "

    http://www.denisbauer.com/ASPNETControls/DynamicControlsPlaceholder.aspx


    "DJ Dev" <> wrote in message
    news:...
    > Hi All,
    > I have a complex problem. I have dropdownlists (usually 3-5) and the
    > user selects some value from these and for each value selected,
    > datagrids are shown to the user. I am creating the Datagrids
    > dynamically using a loop depending on the number of Dropdownlists. The
    > datagrids also have a checkbox template column. Now my problem is that
    > how can I access the values selected by the user from these
    > checkboxes. He checks one or more checkboxes for each of the datagrid.
    > I am assigning unique ids to datagrids while creation. When the page
    > postsback, the datagrid is reconstructed dynamically. Can I use
    > viewstate or something to get what the user selected before the
    > datagrid is re-built on postback.
    > Thanks!
     
    Ken Cox [Microsoft MVP], Feb 8, 2004
    #2
    1. Advertising

  3. DJ Dev

    Jos Guest

    "DJ Dev" <> wrote in message
    news:...
    > Hi All,
    > I have a complex problem. I have dropdownlists (usually 3-5) and the
    > user selects some value from these and for each value selected,
    > datagrids are shown to the user. I am creating the Datagrids
    > dynamically using a loop depending on the number of Dropdownlists. The
    > datagrids also have a checkbox template column. Now my problem is that
    > how can I access the values selected by the user from these
    > checkboxes. He checks one or more checkboxes for each of the datagrid.
    > I am assigning unique ids to datagrids while creation. When the page
    > postsback, the datagrid is reconstructed dynamically. Can I use
    > viewstate or something to get what the user selected before the
    > datagrid is re-built on postback.
    > Thanks!


    First, you need to reconstruct the datagrids in the same way as before
    the postback (with the same id's) first. Then, automatically, you get
    viewstate, and you can handle the user's selections.

    After that, you reconstruct the datagrids once more, in whatever
    way is appropriate for the new page.

    --

    Jos Branders
     
    Jos, Feb 8, 2004
    #3
  4. DJ Dev

    DJ Dev Guest

    Thanks Jos. That is the problem. I construct the datagrid with the
    same id's and in the same way. But I still dont see the user
    selections. Do I have to save the user selection in view state or
    something. I am really confused. I can provide sample code.
    Thanks for the help.

    "Jos" <> wrote in message news:<>...
    > "DJ Dev" <> wrote in message
    > news:...
    > > Hi All,
    > > I have a complex problem. I have dropdownlists (usually 3-5) and the
    > > user selects some value from these and for each value selected,
    > > datagrids are shown to the user. I am creating the Datagrids
    > > dynamically using a loop depending on the number of Dropdownlists. The
    > > datagrids also have a checkbox template column. Now my problem is that
    > > how can I access the values selected by the user from these
    > > checkboxes. He checks one or more checkboxes for each of the datagrid.
    > > I am assigning unique ids to datagrids while creation. When the page
    > > postsback, the datagrid is reconstructed dynamically. Can I use
    > > viewstate or something to get what the user selected before the
    > > datagrid is re-built on postback.
    > > Thanks!

    >
    > First, you need to reconstruct the datagrids in the same way as before
    > the postback (with the same id's) first. Then, automatically, you get
    > viewstate, and you can handle the user's selections.
    >
    > After that, you reconstruct the datagrids once more, in whatever
    > way is appropriate for the new page.
     
    DJ Dev, Feb 8, 2004
    #4
  5. DJ Dev

    DJ Dev Guest

    You can see what I am doing here..

    http://67.126.110.21:8080/Project1/Procsel.aspx

    http://67.126.110.21:8080/Project1/codebehind.txt

    Basically, the user selects something from dropdownlist, choose some
    checkboxes and submits. In the submit event handler, I am re-creating
    the datagrid, otherwise it wont show up. But when i do that I also
    loose the checkboxes selected. how can i capture that before I
    recreate the grid. I have also provided the code-behind. please note
    that the dropdowns and data-grids are DYNAMIC and created at runtime.
    Thanks for the help!


    (DJ Dev) wrote in message news:<>...
    > Thanks Jos. That is the problem. I construct the datagrid with the
    > same id's and in the same way. But I still dont see the user
    > selections. Do I have to save the user selection in view state or
    > something. I am really confused. I can provide sample code.
    > Thanks for the help.
    >
    > "Jos" <> wrote in message news:<>...
    > > "DJ Dev" <> wrote in message
    > > news:...
    > > > Hi All,
    > > > I have a complex problem. I have dropdownlists (usually 3-5) and the
    > > > user selects some value from these and for each value selected,
    > > > datagrids are shown to the user. I am creating the Datagrids
    > > > dynamically using a loop depending on the number of Dropdownlists. The
    > > > datagrids also have a checkbox template column. Now my problem is that
    > > > how can I access the values selected by the user from these
    > > > checkboxes. He checks one or more checkboxes for each of the datagrid.
    > > > I am assigning unique ids to datagrids while creation. When the page
    > > > postsback, the datagrid is reconstructed dynamically. Can I use
    > > > viewstate or something to get what the user selected before the
    > > > datagrid is re-built on postback.
    > > > Thanks!

    > >
    > > First, you need to reconstruct the datagrids in the same way as before
    > > the postback (with the same id's) first. Then, automatically, you get
    > > viewstate, and you can handle the user's selections.
    > >
    > > After that, you reconstruct the datagrids once more, in whatever
    > > way is appropriate for the new page.
     
    DJ Dev, Feb 9, 2004
    #5
  6. DJ Dev

    Jos Guest

    DJ Dev wrote:
    > You can see what I am doing here..
    >
    > http://67.126.110.21:8080/Project1/Procsel.aspx
    >
    > http://67.126.110.21:8080/Project1/codebehind.txt


    These links don't seem to work.

    > Basically, the user selects something from dropdownlist, choose some
    > checkboxes and submits. In the submit event handler, I am re-creating
    > the datagrid, otherwise it wont show up.


    Try recreating the datagrid in Page_Load or Page_Init.
    In the submit event handler is too late, because viewstate is added before
    that.

    --

    Jos Branders
     
    Jos, Feb 9, 2004
    #6
  7. DJ Dev

    DJ Dev Guest

    Sorry for the inconvineance. The links are :

    http://67.126.110.20:8080/Project1/Procsel.aspx

    http://67.126.110.20:8080/Project1/codebehind.txt

    These links do work. Thanks for the help!


    "Jos" <> wrote in message news:<#C7j#>...
    > DJ Dev wrote:
    > > You can see what I am doing here..
    > >
    > > http://67.126.110.21:8080/Project1/Procsel.aspx
    > >
    > > http://67.126.110.21:8080/Project1/codebehind.txt

    >
    > These links don't seem to work.
    >
    > > Basically, the user selects something from dropdownlist, choose some
    > > checkboxes and submits. In the submit event handler, I am re-creating
    > > the datagrid, otherwise it wont show up.

    >
    > Try recreating the datagrid in Page_Load or Page_Init.
    > In the submit event handler is too late, because viewstate is added before
    > that.
     
    DJ Dev, Feb 9, 2004
    #7
  8. DJ Dev

    DJ Dev Guest

    Any Help would be highly appreciated!
    Thanks.

    (DJ Dev) wrote in message news:<>...
    > Sorry for the inconvineance. The links are :
    >
    > http://67.126.110.20:8080/Project1/Procsel.aspx
    >
    > http://67.126.110.20:8080/Project1/codebehind.txt
    >
    > These links do work. Thanks for the help!
    >
    >
    > "Jos" <> wrote in message news:<#C7j#>...
    > > DJ Dev wrote:
    > > > You can see what I am doing here..
    > > >
    > > > http://67.126.110.21:8080/Project1/Procsel.aspx
    > > >
    > > > http://67.126.110.21:8080/Project1/codebehind.txt

    > >
    > > These links don't seem to work.
    > >
    > > > Basically, the user selects something from dropdownlist, choose some
    > > > checkboxes and submits. In the submit event handler, I am re-creating
    > > > the datagrid, otherwise it wont show up.

    > >
    > > Try recreating the datagrid in Page_Load or Page_Init.
    > > In the submit event handler is too late, because viewstate is added before
    > > that.
     
    DJ Dev, Feb 10, 2004
    #8
    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. moondaddy
    Replies:
    4
    Views:
    108,661
    TN Bella
    Jun 22, 2004
  2. yurps
    Replies:
    1
    Views:
    6,907
    rajeshthangarasu1983
    Feb 29, 2008
  3. Jim Bancroft
    Replies:
    4
    Views:
    871
  4. Wayne Wengert

    Determine Which Checkboxes are Checked

    Wayne Wengert, Feb 5, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    2,914
    Wayne Wengert
    Feb 5, 2006
  5. Tim Zych
    Replies:
    2
    Views:
    177
    Tim Zych
    Nov 28, 2005
Loading...

Share This Page