Selecting Multiple Checkboxes inside the GridView Control

Selecting values from the checkboxes inside the GridView control is pretty simple. Check out the code below.
// 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); 
            }                
       }
Checkout the complete article: Selecting Checkboxes inside the GridView Control

Print | posted @ Saturday, July 23, 2005 4:42 PM

Twitter