Hi
You may try like this
<asp:CheckBox AutoPostBack="true" OnCheckedChanged="chkOpt_Changed" itemId='<%# Container.ItemIndex %>' ID="chkOpt" runat="server" Text='<%# Eval("Name") %>' />
.
If you want to access the row where the checkbox included then one way is using the custom attribute as I shown above the
ItemId
. Other option is through the
Parent
property.
For example in the check changed event
protected void chkOpt_Changed(object sender, EventArgs e)
{
CheckBox chk = (CheckBox)sender;
int rowId = Convert.ToInt32(chk.Attributes["itemId"]);
GridViewRow row = (GridViewRow)chk.Parent.Parent.Parent.Parent;
int parentGridRowIndex = row.RowIndex;
}
Good luck