November 24th, 2003, 03:13 PM
Converting a DateTimePicker value in null ?
I am coding in Vb.Net
I knew it was possible (or I am pretty sure it was) in vb.6 to use the null in a datetimepicker.
I need to have 2 dateTimePicker cause at first it was only textbox that were validated, but I got a request from some users that they wanted to see a Calender at this place.
I have one that is the Date I received the documents and the other one is the date the document has been send back.
for the first one, I don't have problem, there is always a value in it, today or another one.
but for the second one. if the documents haven't been send back yet, the value need to be Nothing, it's need to be empty. but I haven't found any way to do it.
when I do, DateTimePicker1.Value = System.DBNull.Value
it's just tell me that a DbNull.Value can't be converted to a date value.
What's should I do then ?
my boss told me that January 1 of 1900 is a null value but that's not true, I haven,t found anything about it. and that way it will be complicate for the user to delete de date, he won't remeber to change it for january 1, 1900
Any one got any idea on how I could go and get all of this out and running ?
November 25th, 2003, 07:55 PM
Are you putting this in a database and have to make the field NULL.
Private Sub btnClear1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear1.Click
'This Clears the Media Date and sets it to DBNULL
Me.dsPhotoInfo.Tables("PhotoInfo").Rows(0).Item(3) = System.DBNull.Value
November 26th, 2003, 09:37 AM
No, what I wanted to do is the inverse. I want the datetimepicker to be at null if it's need to.
It's read the information from the database and add the date to the datetimepicker but sometimes the date in the database is null, soo I need to add a Null Value to the datetimepicker.
and the user also need to have the possibility to choose a null value for the date to record it in the database.
November 26th, 2003, 11:31 AM
what you could do is this have a default value if it is null. Like January 1 of 1900 so when you save the record back to the database use the datepicker validation if equal to January 1 of 1900 then set the value for that field in the database to System.DBNull.Value. I have had similiar issues with the datepicker control. It is great to use but has some issue that is to bad.
December 2nd, 2003, 05:07 PM
yeah that's the samething I was thinking of doing. But it could complicate some people. You would need to go choose that date everytime the user want a date :S ! that's bad imo.
also, because the users check the textbox and if it's empty it,s mean that the document haven't been sent, if there is a value, that's mean it's haven been sent. soo with a date in a datapicker with will be more complicate may be for them
I don't know what to do lol