Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Boolean validation
Message
From
04/05/2006 17:27:41
Jeff Corder
Ambit Technologies, LLC
Missouri, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Boolean validation
Miscellaneous
Thread ID:
01119418
Message ID:
01119418
Views:
83
I've run across an interesting combination of events and I'm hoping someone can illuminate me on what's going on...

I have a boolean column in my table, marked not null. I want either a true or false. So far it seems simple.

I am using a checkbox (set to false) on the form. When the save button is pressed, if the user hasn't CHANGED the value of the checkbox, the value of the boolean field in the DataRow remains null. [This makes sense, if the user doesn't change anything, it remains the same.]

The entity then checks using .GetNonNullableDbValue() and crashes (casting the null to bool). I understand it SHOULD not be null, but it is. In most cases, this would be an error, but during data validation, it should just complain that the value is invalid and notify the user.

Then it gets interesting...
If I go and set checkbox to Checked, all is well with the world. If I set it to unchecked, when it calls the IsEmpty(bool) function, it returns true if the value is false (i.e. it will only accept True as a valid value).

My thinking is that the solution is the booleans must all have default values and be nullable.

Jeff
Next
Reply
Map
View

Click here to load this message in the networking platform