How to delete a value from a textbox bound to a decimal field?

I am developing a Windows app that has quite a few controls bound to a dataset.  The dataset is created from a single SQL Server 2000 table.  

If a textbox is bound to a field who's DataType is 'decimal' in the database table, then I cannot delete the value in the textbox.  Changing the value to another decimal value works fine, but deleting the value seems to be interpreted as an empty string and not accepted as a decimal value.

I usually appreciate this automatic validation in databound controls, but now I need to have the ability to remove a decimal value from the database instead of just being able to change it.

How do I get around this???  Thanks.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

does the database field 'Allow nulls' ??
jtdaggerAuthor Commented:
Yes, the fields allow nulls.
then you should check the changed value and if its zero u have to change its value to null.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

jtdaggerAuthor Commented:
I was hoping to get a little more explanation on how people get around this.  There must be others that have found themselves in this same situation.  I developed some code to validate the fields and adjust the dataset as needed.  I'll split the point between the 2 people that responded.
what do you mean exactly with deleting the value?
if you set its value to null it means that the value is beeing deleted.
you have to remember that null does not stand for 0.0.
jtdaggerAuthor Commented:
'deleting the value' refers to actually removing all text from the TextBox control.  You are correct about null and 0.0 are not the same.  If I enter 0.0 into a decimal bound TextBox, then the value is correctly written to the bound field.  The problem is when I want to completely remove the value from the TextBox.  I delete the value in the TextBox then set the focus to a different control, this results in the first TextBox being set back to the decimal value it had before I deleted it.  

I am assuming that this happens because the TextBox is trying to convert the empty string to a decimal value.  When that doesn't work, it automatically reverts back to the last decimal value.

I have a method (called by each TextBox's TextChanged event) that checks to see if the .Text property is equal to an empty string.  If it is, then I use the .BindingMemberInfo property to determine what field the control is bound to and manually write a System.DBNull.Value to the bound DataSet.  This works fine, but it still seems like a TextBox should know how to handle this on it's own.
yes, it should be.
maybe you should make a new derived textbox which handle it.
but you will have to check if the datatable allows null.
jtdagger ... I just ran across the same problem in my app.  I'd be interested to know if you've found a better solution than using the TextChanged event.  If not, could you share how you access the dataset to be sure you update the correct row & column?  
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.