I am trying to understand why the RadDatePicker will not populate the Input field with just calling the following statement in the PreRender method?
For me to get the value to populate to the DatePicker textbox I have to add this assignment:
Can someone please explain why that is needed?
I have a RadComboBox and upon selection of its SelectedIndexChanged event method that works without even having to set the additional DateInput.SelectedDate as you can see in this little code snippet.
I am not sure why you have to set the DateInput.SelectedDate in the PreRender to make it bubble up to the DatePicker's textbox.
I am using the SharedCalendar control and not sure if that makes a difference.
Just for completeness here is the aspx telerik elements:
protected void RadDatePickerStart_PreRender(object sender, EventArgs e) |
{ |
if (!RadDatePickerStart.SelectedDate.HasValue) |
{ |
RadDatePickerStart.SelectedDate = DateTime.Today.AddDays(-1); |
} |
} |
For me to get the value to populate to the DatePicker textbox I have to add this assignment:
RadDatePickerStart.DateInput.SelectedDate = DateTime.Today.AddDays(-1); |
Can someone please explain why that is needed?
I have a RadComboBox and upon selection of its SelectedIndexChanged event method that works without even having to set the additional DateInput.SelectedDate as you can see in this little code snippet.
protected void rcbDateRange_SelectedIndexChanged(object sender, EventArgs e) | |
{ | |
//Dates should be disabled unless Custom has been selected | |
RadDatePickerStart.Enabled = false; | |
RadDatePickerEnd.Enabled = false; | |
switch (rcbDateRange.SelectedValue) | |
{ | |
case "WeekSun": | |
RadDatePickerStart.SelectedDate = DateTime.Today.AddDays(-5); | |
RadDatePickerEnd.SelectedDate = DateTime.Today.AddDays(-1); | |
break; | |
case "custom": | |
RadDatePickerStart.SelectedDate = DateTime.Today.AddDays(-1); | |
RadDatePickerEnd.SelectedDate = DateTime.Today.AddDays(-1); | |
RadDatePickerStart.Enabled = true; | |
RadDatePickerEnd.Enabled = true; | |
break; | |
default: | |
RadDatePickerStart.SelectedDate = DateTime.Today.AddDays(-1); | |
RadDatePickerEnd.SelectedDate = DateTime.Today.AddDays(-1); | |
break; | |
} | |
} |
I am not sure why you have to set the DateInput.SelectedDate in the PreRender to make it bubble up to the DatePicker's textbox.
I am using the SharedCalendar control and not sure if that makes a difference.
Just for completeness here is the aspx telerik elements:
<telerik:RadComboBox ID="rcbDateRange" AllowCustomText="false" Skin="WebBlue" OnSelectedIndexChanged="rcbDateRange_SelectedIndexChanged" |
AutoPostBack="true" runat="server"> |
<Items> |
<telerik:RadComboBoxItem Text="Yesterday" Value="Yesterday" Selected="True" runat="server" /> |
<telerik:RadComboBoxItem Text="Week To Date (Starts Sun)" Value="WeekSun" runat="Server" /> |
<telerik:RadComboBoxItem Text="Week To Date (Starts Mon)" Value="WeekMon" runat="server" /> |
<telerik:RadComboBoxItem Text="Prior Week (Sun-Sat)" Value="PriorSun" runat="server" /> |
<telerik:RadComboBoxItem Text="Prior Week (Mon-Sun)" Value="PriorMon" runat="server" /> |
<telerik:RadComboBoxItem Text="Month to Date" Value="MonthToDate" runat="server" /> |
<telerik:RadComboBoxItem Text="Prior Month" Value="PriorMonth" runat="server" /> |
<telerik:RadComboBoxItem Text="Quarter to Date" Value="QuarterToDate" runat="server" /> |
<telerik:RadComboBoxItem Text="Prior Quarter" Value="PriorQuarter" runat="server" /> |
<telerik:RadComboBoxItem Text="Year to Date" Value="YearToDate" runat="server" /> |
<telerik:RadComboBoxItem Text="Prior Year" Value="PriorYear" runat="server" /> |
<telerik:RadComboBoxItem IsSeparator="true" runat="server" /> |
<telerik:RadComboBoxItem Text="Custom Range" Value="custom" runat="server" /> |
</Items> |
</telerik:RadComboBox> |
<telerik:RadDatePicker ID="RadDatePickerStart" SharedCalendarID="sharedCalendar" OnPreRender="RadDatePickerStart_PreRender" |
Skin="WebBlue" Enabled="false" runat="server"> |
<DateInput ID="rdpStartInput" ReadOnly="true" runat="server" /> |
</telerik:RadDatePicker> |
<telerik:RadDatePicker ID="RadDatePickerEnd" SharedCalendarID="sharedCalendar" OnPreRender="RadDatePickerEnd_PreRender" |
Skin="WebBlue" Enabled="false" runat="server"> |
<DateInput ID="rdpEndDateInput" ReadOnly="true" runat="server" /> |
</telerik:RadDatePicker> |
<telerik:RadCalendar ID="sharedCalendar" RangeMinDate="2005-04-01" runat="server" |
EnableMultiSelect="false" Skin="WebBlue" Width="200px" ShowRowHeaders="false" |
OnPreRender="sharedCalendar_PreRender" UseColumnHeadersAsSelectors="false"> |
</telerik:RadCalendar |