Click here to Skip to main content
16,021,041 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
myConnection.Open()
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)
fn_AttachGrid(empmail)
Else
End If
End While
myReader.Close()
myConnection.Close()
Else
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
Posted

1 solution

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

C#
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             
   }         
 } 
} 
 
Share this answer
 
Comments
mani.kishore.asp.net 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