Print Page | Close Window

Integer values being 0

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=780
Printed Date: 23-Apr-2024 at 4:05am


Topic: Integer values being 0
Posted By: DataMan
Subject: Integer values being 0
Date Posted: 22-Apr-2008 at 8:45am

I have a form with a textbox on it (added using devforce) that is tied to an integer field in SQL.

I added a verifier to the field that this textbox is bound to which says that the value is required and the min value is 1.

 
When I add a new record using the create method, the value 0 automatically gets entered into the text box.  If I don’t change that value or tab into the field I am allowed to save the record even though it is 0.  No error message occurs.

 

The same thing is happening with all of my comboboxes that are tied to integer values.

 

Do I need to add my own validation of those text boxes(!=0)/comboboxes(notinlist) and throw an error of my own or is there a way to do it in Ideablade?

 
Thanks



Replies:
Posted By: davidklitzke
Date Posted: 22-Apr-2008 at 7:49pm
Creating a new entity is one place where some of the properties of a business object can escape verification.  If a property is a required property, it must be initialized in the process of creation.  Furthermore, if it is an integer field, it will be initialized to zero.
 
There are at least two solutions/workarounds to this problem.
 
(1) In the creation code, make sure there are no uninitialized fields that would break verification rules if set to the default value (e.g., an integer field set to 0).  This is the quick (but by no means foolproof) method.
 
(2) Use Instance Verification immediately after creating a business object.  This is the sure way (although it is a little more work).  Read more about Instance Verification in the "Developer's Guide".


Posted By: DataMan
Date Posted: 25-Apr-2008 at 10:01am
Number 1 is an interesting idea because then if what you set in code for the value to be isn't what the user wants they will change it.
 
Number 2 - I've looked into this and while it works really well I was assuming that when i called the instance verification that it would turn on the ErrorProvider on the form for the field that failed.  Without me doing some research and taking the easy way out by asking you :-) Is there any way to, upon verification, get the errorproviders flashing for items that don't validate?
 
Thanks
 



Print Page | Close Window