Solved

Set datetime property to null when deleting date

Posted on 2009-03-30
1
394 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

729 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