How to select the checkboxes inside the Gridviewcontrol
After seraching many forums and websites i have developed my project by using this code.
Now in the button click event write this code which i have attached in blog as image:
// 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("chkBox")).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());
No comments :
Post a Comment