Solved

Set datetime property to null when deleting date

Posted on 2009-03-30
1
388 Views
Last Modified: 2013-12-17
How do you enable deletion of a date value in a textbox bound to a strongly typed datarow of column type system.datetime? The textbox is bound to a binding source which has its datasource set to the datarow.

When I delete the date from the textbox and click on save on my form I update the dataset which seems to work fine, however when I come back to that record the old date is still there.

I assume this is because an empty string cannot be converted to a date so the stringly typed datarow cannot be updated.

I know this should be simple as it is a pretty standard operation but I have not been able to find a simple solution for this.

Can anyone help?
0
Comment
Question by:bencmorrow
1 Comment
 
LVL 9

Accepted Solution

by:
VikramMullick earned 500 total points
Comment Utility
DateTime column will always have some date associated with it.
So when you delete data from textbox , set the column value to  the value like new datetime(1800,0,0) ,
which is not normaly used.
While binding data , just take care to appplyternary data , that if date is in that format , assign the value of
textbox to string.empty
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now