I have a column of checkboxes to select the records in the gridview but i am struggling to determine which checkboxes were checked on postback caused by button click.I used the following code but it doesnt work.
protected void btnSave_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox cb = (CheckBox)row.FindControl("Chkgridselect");
if (cb.Checked)
{
int id = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
}
}
}
Can anyone please rectify the above coding?