This is a migrated thread and some comments may be shown as answers.

RadDateTimePicker NullDate Bug

1 Answer 127 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Chris Ward
Top achievements
Rank 1
Chris Ward asked on 13 Feb 2015, 07:25 PM
I have a RadDateTimePicker control defined as follows:

datePicker.NullText = "No date...";
datePicker.NullDate = DateTime.Parse("1900-01-01");

When I set

datePicker.NullableValue = DateTime.Today;

datePicker.Value also changes to today.

However, when I set

datePicker.NullableValue = null;

or call

datePicker.SetToNullValue();

datePicker.Value is set to "0001-01-01" regardless of what my NullDate is.

Why is Value not set to NullDate when NullableValue is set to null? How do I get rid of the garbage date, in year "0001"?

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 17 Feb 2015, 05:01 PM
Hi Chris,

Thank you for writing.

The NullDate property sets a date which if gets selected will display in RadDateTimePicker the value of the NullText property. The only difference of the NullableValue property and the Value property is just that it also accepts null. Setting the NullableValue to null or calling the SetToNullValue method will clear the selection in the calendar, however on the next opening in the calendar it will show the last selected date. For additional information please read the following articles: RadDateTimePicker Properties and Set Null or Empty Value.

If you would like to explicitly focus on the NullDate and have your RadDateTimePicker.Value equal to the NullDate, I would suggest calling the SetValueOnly method of the DateTimePickerElement. Please see my code snippet below:
private void SetValueToNull(object sender, EventArgs e)
{
    this.radDateTimePicker1.SetToNullValue();
    this.radDateTimePicker1.DateTimePickerElement.SetValueOnly(this.radDateTimePicker1.NullDate);
}

I hope this information helps. Should you have further questions, please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Chris Ward
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or