Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Boolean validation
Message
De
04/05/2006 17:27:41
Jeff Corder
Ambit Technologies, LLC
Missouri, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Boolean validation
Divers
Thread ID:
01119418
Message ID:
01119418
Vues:
79
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform