I need to populate a checkbox in asp C# based on a value of 0 or 1 from my database.
SqlCommand Comm1 = new SqlCommand("Select Active from dbo.SQLInfrastructure WHERE [Instance] LIKE '" + label1.Text + "%'", connn);
connn.Open();
SqlDataReader DR1 = Comm1.ExecuteReader();
if (Comm1==1)
{
this.activeCheckBox.Checked = false;
}
else
{
this.activeCheckBox.Checked = true;
}
connn.Close();
I believe I am close, this is on the page_load event. This code does not work but conveys what I am trying to accomplish.