RadDateTimePicker NullDate Bug

2 posts, 0 answers
  1. Chris Ward
    Chris Ward avatar
    52 posts
    Member since:
    Jan 2010

    Posted 13 Feb 2015 Link to this post

    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"?
  2. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 17 Feb 2015 Link to this post

    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.

     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top