-->

Set default value of RadDatePicker to NULL when da

2019-03-06 14:47发布

问题:

I'm binding the RadDatePicker to a viewModel dateTime property. when the property is null in database i get 01/01/0001. How to i change this behavior to just leave the date field blank.. example:

In database ===> experiation_date : NULL In View(GUI) ===> experation_date : 01/01/0001

Expected Result ===> experation_date : {Blank}

回答1:

Set the SelectedDate to null (and not DBNull):

RadDatePicker1.SelectedDate = null;

and in xaml set DateTimeWatermarkContent to the empty string:

<telerik:RadDatePicker x:Name="RadDatePicker1" DateTimeWatermarkContent="" />