954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to get selected checkboxes

I am unable to update table when the users clicks on the register button. My code is listed below.

vb:
Dim retstruct As RegisterCourseInfo
Dim uN As String


For Each row As GridViewRow In GridView1.Rows
Dim cb As CheckBox = CType(GridView1.FindControl("ChkSelect"), CheckBox)

If cb IsNot Nothing AndAlso cb.Checked Then

uN = GridView1.DataKeys(row.RowIndex).Value
retstruct = RegisterCourseIndividual(Request.QueryString("Cour seID"), Request.QueryString("SessionID"), uN, False)
cb.Checked = False

End If
Next

Would anyone have any ideas of why I am not getting the correct resluts?

Thank you in advance for looking.

teklaw
Newbie Poster
1 post since Dec 2011
Reputation Points: 10
Solved Threads: 0
 
For Each row As GridViewRow In GridView1.Rows
Dim cb As CheckBox = CType(GridView1.FindControl("ChkSelect"), CheckBox)


I believe you should be looking for the control inside the row, not the whole grid.
ie:

For Each row As GridViewRow In GridView1.Rows
Dim cb As CheckBox = CType(row.FindControl("ChkSelect"), CheckBox)
Hearth
Posting Whiz in Training
224 posts since Apr 2008
Reputation Points: 106
Solved Threads: 33
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: