I am trying to set / change the DateTimePicker value (using vb.net) but can't work out how to do it.
I have added the control to the page and I have tried using the following code but it doesn't work and I can't work out how to set the value during run-time.
DateTimePicker1.Value = Now.Day & "-" & Now.Month & "-" & Now.Year
The format of the control is set to Long and it looks like this when first loaded:
Tuesday, February 26, 2013
But I can't work out how to change it.
The error I get based on my code above is:
Conversion from string "26-2-2013" to type 'Date' is not valid.
Anyone got any ideas ?
I ended up getting it working by doing the following:
DateTimePicker1.Value = New Date(2013, 2, 26)
I was loading the value wrong.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With