Solved

Simple checkBox question

Posted on 2004-04-28
2
232 Views
Last Modified: 2010-04-15
I have the following checkBox I am trying to display on my form but it show unchecked even though the data shows checked.

checkBox1.Text=datareader["Active"].ToString();

Any idea hoew to get it to properly display?

Jim
0
Comment
Question by:Jimbo456
2 Comments
 
LVL 21

Accepted Solution

by:
tovvenki earned 250 total points
ID: 10945852
Hi,
If the datareader["Active"] is a bit or boolean then assign it straight to the Checked property of the checkbox and not to the text property.
 or if the datareader returns a string like Checked then
checkBox1.Text=datareader["Active"].ToString();
if (checkBox1.Text == "Checked")
      checkBox1.Checked = true;
else
      checkBox1.Checked = false;


Regards,
Venki
0
 
LVL 1

Expert Comment

by:warmach
ID: 10948564
You should not be setting the Text property at all.  This property is used as a label to the check box.  Link Venki said, you need to set the Checked property directly.  I would set the Text property to something more descriptive because it is something that the user will see.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question