Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > DatePicker > Default to Today when null

Not answered Default to Today when null

Feed from this thread
  • Posted on Aug 10, 2011 (permalink)

    My date picker is bound to a DateTime field, but on the UI, the control allows the user to "delete" the value. This causes the validation to throw an error "Value '' cannot be converted". Is there any way to set the control to the current datetime when the user "deletes" the date in the box?

    I'm also having this trouble with a bound combobox that doesn't allow null values. I want the user to be able to type in to select a value, but that means they can also remove the value (which causes the same error).

    Reply

  • Posted on Aug 10, 2011 (permalink)

    I managed to work around it by handling the SelectionChanged event and checking for a SelectedValue. If null, then I set to DateTime.Now.
    I also did the same thing with the combobox. if selected item is null, I set selectedvalue to 0 to trigger the data validation.

    Is this the best way to handle this?

    Reply

  • Boyan Boyan admin's avatar

    Posted on Aug 11, 2011 (permalink)

    Hi Rayne,

    For RadDatePicker you can also use the ParseDateTimeValue event and to implement your custom logic there. As for the RadComboBox I can't think of another way this can be done.

    Best wishes,
    Boyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > DatePicker > Default to Today when null
Related resources for "Default to Today when null"

WPF DatePicker Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]