passing back null to a database field if textbox is blank

  • Thread starter Thread starter Wishing I was skiing mom
  • Start date Start date
W

Wishing I was skiing mom

I have a text box that represents Hours worked, I also have a text box that
represents Adjusted Hours worked. If user wants to override the Hours worked
they enter a value in the Adjusted Hours worked text box. In doing so the
Adjusted hours worked field in the database would then be updated to the
value entered, but in the event the user doesn't enter an adjusted hours
figure the database field should contain Null. How do I pass the value null
from the adjusted hours worked text box, since it would be blank(empty, =
nothing, or whatever) to the database field?

Any help would be greatly appreciated, thanks in advance.
Jackie
 
Is the textbox databound? If so, you can capture the Format and Parse
events. In the Format event, check the db value for null and display
string.Empty; in the Parse event, check the value in the textbox for
string.Empty and set it to DBNull.

If it's not data bound, can't you just handle it when you unload your
textbox into the dataset?

RobinS.
 
The textbox is not databound and I ended up updating the db field only if the
user entered a numeric value otherwise db field was unchanged, as the db
field default is null. This required additional code and additional update
processes that I was hoping I could avoid. I am thinking there must be a
better way, but need to move on from this.
Thanks,
Jackie
 
Back
Top