RadTimePicker showing error as " 'SelectedDate' should be between 'MinDate' and 'MaxDate'".

6 posts, 0 answers
  1. Soumya
    Soumya avatar
    108 posts
    Member since:
    Jul 2012

    Posted 16 Jul 2012 Link to this post

    I have a RadTimePicker in my asp.net application as below.

    <telerik:RadTimePicker ID="RCFromTime" runat="server" Width="110px" Culture="en-US" TimeView-TimeFormat="t" DateInput-DateFormat="h:mm tt" DateInput-DisplayDateFormat="h:mm tt" >
             
             <TimeView StartTime="08:00:00" EndTime="20:00:00" Height="100px" Width="250px" ShowHeader="False" runat="server"> </TimeView>
              <DateInput ID="DateInput1" runat="server">
                                <ClientEvents OnLoad="onLoadRadTimePicker1" />
              </DateInput>
    </telerik:RadTimePicker>

    In the program I am trying to move a time from sql server to the Timepicker to display the time saved as below.

    RCFromTime.DbSelectedDate = phoneenq.Ph_Apptime;

    I am getting an error on the above statement as " Value of '01-01-1900 08:00:00' is not valid for 'SelectedDate'. 'SelectedDate' should be between 'MinDate' and 'MaxDate'.Parameter name: SelectedDate"

    (  Ph_Apptime is declared as -->public DateTime Ph_Apptime { get; set; }  inside the program)

    Anyone please help me on this.





  2. Soumya
    Soumya avatar
    108 posts
    Member since:
    Jul 2012

    Posted 17 Jul 2012 Link to this post

    I have solved the issue.

    default MinDate  value of the RadDatePicker  was 1/1/1980 .
    I have changed the mindate to system date as below.

    RadTimePicker.MinDate = new System.DateTime();

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Jul 2012 Link to this post

    Hi Soumya,

    The error is thrown because "1/1/1900" is out of the default range for the RadDatePicker which is between 1980 and 2099. If you use dates outside of this range you should specify appropriate values for MinDate and MaxDate properties of RadDatePicker.

    Hope this helps.

    Regards,
    Princy.
  5. Soumya
    Soumya avatar
    108 posts
    Member since:
    Jul 2012

    Posted 17 Jul 2012 Link to this post

    Thanks Princy for your reply.
  6. TonyG
    TonyG avatar
    239 posts
    Member since:
    Feb 2006

    Posted 01 Oct 2012 Link to this post

    This is close to what brought me to the forum this time. Here's the full error:

    As Princy said, the problem is that the data coming from the database is not within the Min/Max set for the control. Yes, I do need to establish a min/max so that users don't pick a date outside of a reasonable scope. But if the date on the server is already beyond that scope, I don't want to throw an exception, I'd rather reset the Min or Max to whatever the server data says.

    So I'm thinking the protocol would be to set min/max to something Way out of range, then when the data is loading get the actual min/max values, then in Page_Render ( or a DataBound event? ) reset the min/max to the new default.

    1) Can someone help with that?

    and/or 2) Does anyone see that as being a seriously wrong thing to do? Sure, I can log discrepancies - I just don't want the the browser to halt mid-update (which is what this exception is causing) if the app allows different data values.

    Thanks!
  7. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 04 Oct 2012 Link to this post

    Hello,

    If you use the latest version of RadControls you can set SkipMinMaxDateValidationOnServer property to "true" for the RadDatePicker and the DateInput of the picker.

    Another option will be to change the MinDate and MaxDate of the picker before the binding.

    Greetings,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017