SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2001
    Location
    London
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Remember checkbox selections from gridview

    Hi,
    I have output data into a gridview and placed a asp:checkbox on each row and assigned a asp:hidden form element with the id of the row. When I select a asp:button on the page and attempted to retrieve the checked items I find they have reset to upchecked! Here is the code I am using to retrieve the checkbox:

    For i = 0 To gvUserMessage.Rows.Count - 1

    Dim row As GridViewRow = gvUserMessage.Rows(i)

    Dim CheckBox As CheckBox = row.FindControl("chkSelect")

    If CheckBox.Checked Then

    ' Write out check function here

    Response.Write("TRUE<BR>")

    EndIf

    Next


    Any ideas?
    Oh I have placed this code in the GridView unload event.




  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you are binding the datagrid again before getting the values of the checkbox on button click.

    If it is not the case then can u plz share ur code.


    Pankaj

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2001
    Location
    London
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I have just this minute realised I am doing this.... thanks for much for the feedback!

    I have just seen this article too.

    http://aspnet.4guysfromrolla.com/articles/052406-1.aspx


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •