Solved

Set datetime property to null when deleting date

Posted on 2009-03-30
1
389 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
ID: 24018521
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

20 Experts available now in Live!

Get 1:1 Help Now