Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datetimepicker control returning 1/1/0001?

Status
Not open for further replies.

moongirl129

Programmer
Sep 5, 2002
38
GB
I'm using a datetimepicker control and it's text and value properties are databound to a datetime property of a custom object. The date value defaults to todays date.

If I open the application and enter other data, but don't change the date value in the picker (because I want todays date and that's what it shows) the value that is saved is 1/1/0001. If I change the date the correct value is saved. Why is this and what am I doing wrong - it's driving me mad!
 
You should set the default value of the datetime picker to today - even though it is currently displayed, it is not actually selected.

datatimepicker1.Value = DateTime.Now;
 
Oh dear I knew it would be simple. Actually realised it was because I wasn't setting the objects date propertuy to a default value of today. Thanks though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top