I have populated a gridview with Code, Description, and 5 checkboxes on each row. My goal is to get the Code and what checkbox is checked for each row. These values will then be saved to the database.
Tried the following code.
foreach (GridViewRow row in gvInspections.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
bool checkedcell = (bool)gvInspections.Rows[i].Cells[3].Text;
System.Web.UI.WebControls.CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as System.Web.UI.WebControls.CheckBox);
if (chkRow.Checked)
{
MessageBox.Show("Yes");
}
}
}
For each row in the grid I expect to know which box is checked.
Aucun commentaire:
Enregistrer un commentaire