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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mamta MPosted Nov 3, 2008, 5:01 AM
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