Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Set datetime property to null when deleting date

Posted on 2009-03-30
1
Medium Priority
?
399 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

609 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