Solved

Set datetime property to null when deleting date

Posted on 2009-03-30
1
392 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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