Solved

Simple checkBox question

Posted on 2004-04-28
2
231 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

774 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