I want to read NULL values from database, if its not NULL I want to make the checkboxes checked but this code is not working.
if (dr["p51"] != null)
{
chkP51.Checked = true;
}
I want to read NULL values from database, if its not NULL I want to make the checkboxes checked but this code is not working.
if (dr["p51"] != null)
{
chkP51.Checked = true;
}
Check the values null by using DataRow.IsNull(string columnName). Change your code like this.
if (!dr.IsNull("p51"))
{
chkP51.Checked = true;
}
Finally from @Kevin Rodriguez suggestion,because dr["p51"]
return 0
if ((string)dr["p51"] == "0")
{
chkP51.Checked = true;
}