|
Maintaining the difference between a zero and null value in ASP.NET In an ASP.NET project I am taking a value from a TextBox that the user will input a "foo" (customer term) value as a string. The tensile value is an attribute of the "bar" class.
This foo value will be a integer from 0 to 1000. In the case that the TextBox is left blank, the input should not be parsed and entered into the database row as a 0 but rather as a null. This is because reports that run will include a 0 value in averaging calculations but ignore a null.
What is the simplest way to hand this? I wanted to use accessors to set the value of the private int variable to null when the string was equal to an empty string, but C# won't let me assign null to the variable. It seems like I may have to define a seperate Foo class as an variable of the Bar object so that foo can also hold a notation that the value should be null.
Then I'm hoping I can use a DataSet to simply change the value of a column value in a DataRow and then have the DataAdapter manage whether the information is stored in the table as an integer zero or a null.
Thoughts?
Update: Problem solved. Update to be posted soon.
1 Comments | #6683
Unless noted, all content on epistolary.org is © Copyright 1999-2008 to Rob Carlson with all rights reserved. All information is verified when possible, cited as appropriate and applied in the real world at your own risk.
Send all feedback to rob@vees.net.
|
franco wrote:
I believe there was null article and tutorials at http://www.aspunity.com.
Posted on 2008-08-12 15:12:43