This is a migrated thread and some comments may be shown as answers.
RadDatePicker vs System.Datetime()
2 Answers 68 Views
This is a migrated thread and some comments may be shown as answers.
Olga
Top achievements
Rank 1
Olga asked on 15 Feb 2011, 05:33 AM
Hi,

I am debugging an application that has just been upgraded to the ASP.NET AJAX controls from Classic.  I ran into the following problem.  I have these two lines of code:

RadDatePicker minValDate = new RadDatePicker();
minValDate.SelectedDate = new System.DateTime();

The second line gives me an error.  "Value of '1/1/0001 12:00:00 AM' is not valid for 'SelectedDate'. 'SelectedDate' should be between 'MinDate' and 'MaxDate'.\r\nParameter name: SelectedDate"

According to MSDN "01/01/0001" is a legitimate minimum value of the System.DateTime().  So, I am wondering if there is something I am missing with my RadDatePicker.

Thanks,
Olga

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 15 Feb 2011, 07:04 AM
Hello Olga,

This error occurs because you are trying to set selectedDate which is less than the default MinDate  value of the RadDatePicker. The RadDatePicker's MinDate poperty has a default value of 1/1/1980. So in order to avoid this you need to change the MinDate value. Here is a sample code.
C#
RadDatePicker minValDate = new RadDatePicker();
minValDate.MinDate = new System.DateTime();
minValDate.SelectedDate = new System.DateTime();


Thanks,
Shinu.
0
Olga
Top achievements
Rank 1
answered on 15 Feb 2011, 11:28 PM
Thank you!

Olga
Asked by
Olga
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Olga
Top achievements
Rank 1
Share this question
or