Actually, if you have that problem means where you have placed that CheckBox..?
<asp:templatefield headertext="checkbox" xmlns:asp="#unknown">
<itemtemplate>
<asp:checkbox id="cb" runat="server" />
</itemtemplate>
<edititemtemplate>
<asp:checkbox id="cb1" runat="server" />
</edititemtemplate>
</asp:templatefield>
If you placed that one in ItemTemplate (ie, for 'cb' checkbox)then you can directly access it through
the code which is written by yourself and hitech_ssc
protected void b1_Click(object sender, EventArgs e)
{
foreach (GridViewRow item in gv.Rows)
{
CheckBox checkBox = (CheckBox)item.FindControl("cb");
if (checkBox.Checked)
{
}
}
}
and if you want to access the checkbox=cb1, then
onEditing event
void gv_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
CheckBox checkBox = (CheckBox)gv.Rows[e.RowIndex].FindControl("cb1");
bool isChecked = checkBox.Checked;
if (isChecked)
{
}
}