This is a migrated thread and some comments may be shown as answers.

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

6 Answers 1705 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Soumya
Top achievements
Rank 1
Soumya asked on 17 Jul 2012, 04:48 AM
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.





6 Answers, 1 is accepted

Sort by
0
Soumya
Top achievements
Rank 1
answered on 17 Jul 2012, 05:31 AM
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();

0
Princy
Top achievements
Rank 2
answered on 17 Jul 2012, 05:32 AM
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.
0
Soumya
Top achievements
Rank 1
answered on 17 Jul 2012, 05:33 AM
Thanks Princy for your reply.
0
TonyG
Top achievements
Rank 1
answered on 02 Oct 2012, 01:35 AM
This is close to what brought me to the forum this time. Here's the full error:
 Sys.WebForms.PageRequestManagerServerErrorException:
 Value of '10/12/2012 12:00:00 AM' is not valid for
 'SelectedDate'. 'SelectedDate' should be between 'MinDate' and 'MaxDate'. Parameter name: SelectedDate

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!
0
Vasil
Telerik team
answered on 04 Oct 2012, 02:34 PM
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.
0
Eddy Mix
Top achievements
Rank 1
answered on 24 Jul 2017, 07:03 PM

this answer is fine..
i tried it out..
and it works well.

thanks

Tags
Calendar
Asked by
Soumya
Top achievements
Rank 1
Answers by
Soumya
Top achievements
Rank 1
Princy
Top achievements
Rank 2
TonyG
Top achievements
Rank 1
Vasil
Telerik team
Eddy Mix
Top achievements
Rank 1
Share this question
or