RadDatePicker vs System.Datetime()

3 posts, 0 answers
  1. Olga
    Olga avatar
    20 posts
    Member since:
    Dec 2010

    Posted 14 Feb 2011 Link to this post

    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. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 15 Feb 2011 Link to this post

    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.
  3. Olga
    Olga avatar
    20 posts
    Member since:
    Dec 2010

    Posted 15 Feb 2011 Link to this post

    Thank you!

    Olga
Back to Top