Selecting multiple checkboxes inside a GridView control - From CodeProject.com

Selecting multiple checkboxes inside a GridView control
        By azamsharp

This article describes how you can select checkboxes inside a GridView control. 

http://www.codeproject.com/aspnet/SelChkboxesDataGridView.asp

Code snippet:

//  StringBuilder object
StringBuilder str  =   new  StringBuilder();

//  Select the checkboxes from the GridView control
for  ( int  i  =   0 ; i  <  GridView1.Rows.Count; i ++ )
{
  GridViewRow row 
=  GridView1.Rows[i];
  
bool  isChecked  =  ((CheckBox) row.FindControl( " chkSelect " )).Checked;

  
if  (isChecked)
  {
    
//  Column 2 is the name column
    str.Append(GridView1.Rows[i].Cells[ 2 ].Text);
  }
}

//  prints out the result
Response.Write(str.ToString());

你可能感兴趣的:(checkbox)