Click here to Skip to main content
15,074,483 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dim myCommand As New SqlCommand(sqlselect, myConnection)
Dim myReader As SqlDataReader
myReader = myCommand.ExecuteReader()
If myReader.HasRows Then
While myReader.Read()
Dim isChecked As Boolean = DirectCast(FindControl("chkSelect"), CheckBox).Checked

If isChecked Then
empmail = myReader(column)
End If
End While
End If

i have a gridview and a checkbox item in gridview
when button is pressed it should iterate through all the items where check box is checked

1 solution

Please go through below code, see if it helps. Not sure though if it is your requirement.

protected void Button1_Click(object sender, EventArgs e)     
 // Looping through all the rows in the GridView          
 foreach (GridViewRow di in GridView1.Rows)         
   CheckBox chkBx = (CheckBox)di.FindControl("chkSelect");              
   if (chkBx != null && chkBx.Checked)            
      /// put your code here             
Comments 14-Jun-12 4:53am
thanks for that but my sql while reader

also iterates through all the rows, please suggest for the if condition inside while reader.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900