473,700 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why is boolean column always checked?

I convert a collection to DataSet, reference the first table and throw
that into a DataTable. The DataTable is used as a DataSource for a
DataGrid. The DataGrid has an associated GridTableSyle.

I use the RowChanged() event on a DataTable to capture changed column
data. I get their values and update the collection without errors:

Person.addressc ollection[0].IsMailing =
Convert.ToBoole an(e.Row["IsMailing"].ToString());

When the grid has finished initially loading, the IsMailing boolean
column is grayed and checked. I click it once to give focus. Then
click again to uncheck. It also ungreys on the second click. Once I
move off this column, it grays and checks itself. The value for the
above collection field is always false. That is the value coming off
the grid or the above conversion.

I'm setting readonly to false for the boolean column when setting up
the gridtablestyle. Any ideas why the boolean is acting this way in
the grid?


Jan 17 '06 #1
2 1498
The checkbox in a datagrid has 3 states, i.e. if the data value is NULL
rather than TRUE of FALSE, the checkbox is cheched and grayed. So to
solve this problem, you should set the boolean data value to FALSE if
it is NULL.

Jan 18 '06 #2
I have only one row in the grid. I see the two boolean columns coming
out of the table have true/false values. I supply the grid this way:

dgAddress.DataS ource = dtAddress;

It should be fine. How else can I check if the values are null? I
also have the DataGridBoolCol umn set to AllowNull = false.


Jan 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Patrick.O.Ige | last post by:
I'm DataBinding a CheckBoxList and i want to get the checkboxes selected when the page is loaded depending on a Boolean value from the Database.. chkDebtor.DataSource = objDR chkDebtor.DataValueField = "checked" -- this is a column in the table that returns 1 or 0 chkDebtor.DataTextField = "DebtorCode" chkDebtor.DataBind() Dim i As Integer = 0 While i < chkDebtor.Items.Count
by: Wayne Wengert | last post by:
I have a datagrid bound to dataset where some entries are null. In that grid I am defining a column as Boolean (see code below) and I get the expected checkbox which is checked or unchecked when the DB value is 0 or 1 but when it is null, I get a grayed out checkbox that is checked. I want the null values to display nothing - like with the null text in a textbox. How can I accomplish that? TIA Wayne
by: Gene Hubert | last post by:
I'm using DataTable.ImportRow to move data from one datatable to another... Dim dt, dtTarget As DataTable Dim dr As DataRow dt = DirectCast(Me.DataSource, DataTable) dtTarget = dt.Clone 'copy the data structure dtTarget.DefaultView.Sort = String.Empty 'remove the sort
by: BobAchgill | last post by:
I tried to use either a CheckBox or Radio Button to set a Boolean variable but I get Cast error message with either when I try to use the Boolean in an IF statement. How can I use the Check box control to set the Boolean and not get a cast error later in the code with I try to use the Boolean in an If statement? Thanks!
by: Darek | last post by:
Hi, I have a table, something similar to: create table my_table ( id char(32) not null primary key, num integer not null, code varchar(2) not null, name varchar(60) not null,
by: dba123 | last post by:
Why am I getting this error for Budget? Error: An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code Additional information: String was not recognized as a valid Boolean. Public Sub UpdateCustomer_DashboardGraphs(ByVal sender As Object, ByVal e As System.EventArgs)
by: hazz | last post by:
ICollection CreateDataSource() { dt.Columns.Add(new DataColumn("ReportInclude", typeof(Boolean))); for (int i=0; i<=10; i++) { dr = dt.NewRow(); dr = 0; dt.Rows.Add(dr); } void Page_Load(Object sender, EventArgs e) { ItemsGrid.DataSource = CreateDataSource(); void Item_Bound(Object sender, DataGridItemEventArgs e) {
by: jobs | last post by:
What's messed up here is that i have close to identical code that is working perfectly, only difference is that code uses sqldatasource control instead objectdatasource used here. Getting this error during the update: Server Error. To return to your data and retry, use the BACK button System.ArgumentException: Object of type 'System.Int16' cannot be converted to type 'System.Boolean'. at System.RuntimeType.CheckValue(Object value,...
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I've a DataGridView table which has a boolean column. when the user clicks the boolean cell I'm asking for his conformation, in case he press OK i've no problem, but in case he chooses to cancel, i've a problem that the cell is checked and i don't want it to be checked, i tried with the mouseUp event, i tried to put a timer, nothing helped. How can i cancel the cell checking to true?
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.