hi friends
can anyone help how to check a checkbox while retriving data from database.
hi friends
can anyone help how to check a checkbox while retriving data from database.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mamta MRank #268 · 9.4K reputationPosted Nov 3, 2008, 12:01 AM EST
Hi there,
You can try the following code:
SqlCommand cmd = new SqlCommand("SELECT from " , con);
bool value = Convert.ToBoolean(cmd.ExecuteScalar());
if (value)
{
checkBox1.Checked = true;
}
else
{
checkBox1.Checked = false;
}
Replace the fieldname and tablename as per your requirements, you may also write an entirely new SQL query to retrieve the particular boolean column.
Hope this helps.
Regards,
Mamta