Hello, I'm trying to set the value of a checkbox in a gridview based on another column, but I get the error 'System.NullReferenceException' occurred
This is my code:
protected void gvChecks_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label checkResult = e.Row.FindControl("lblCheckResult") as Label;
if (checkResult.Text == "TRUE")
{
CheckBox cbTrue = (CheckBox)e.Row.FindControl("cbYes");
cbTrue.Checked = true;
}
}
}
catch (Exception ex)
{
myMessageBox(ex.Message);
}
}
I would appreciated any kind of help.
Thank you in advance.