datetimepicker value is always true
Hi,
I've made a datetimepicker with a checkbox in it. Datetimepicker is intended as a filter - the user enters the date and gets filtered the data for that date. dtp is without binding.
The problem is there, if the datetimepicker checkbox is empty, it still retains the value.
Currently datetimepicker constantly feeds value to the database.
So I thought, is that a validation problem or only the properties, but in my case I added checked = true and showcheckedbox = true also or need to looking somewhere else.
Re: datetimepicker value is always true
The Value property is type DateTime, so of course it always has a value. It's up to you to test the value of the Checked property and then use or don't use the Value property. It's not going to magic it for you.
vb.net Code:
If myDateTimePicker.Checked Then
'Use myDateTimePicker.Value here.
Else
'Don't use myDateTimePicker.Value.
End If
Re: datetimepicker value is always true
Quote:
Originally Posted by
jmcilhinney
The Value property is type DateTime, so of course it always has a value. It's up to you to test the value of the Checked property and then use or don't use the Value property. It's not going to magic it for you.
vb.net Code:
If myDateTimePicker.Checked Then
'Use myDateTimePicker.Value here.
Else
'Don't use myDateTimePicker.Value.
End If
Thanks.
Just figured it out, gave value as endDate and it worked.