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

RadTimePicker TimeView incorrect after setting StartTime and EndTime

3 Answers 119 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Jackie
Top achievements
Rank 1
Jackie asked on 14 Jun 2017, 12:33 PM

A pair of RadTimePickers I have for selecting the beginning and end of a shift are displaying the timeview incorrectly after being enabled and having the starttime and endtime values set. They both show every slot from 12AM to 11:45PM, but starting with 12AM selecting a slot displays the value that SHOULD be seen, 8:30AM in this case, and continues for each subsequent slot in the same manner until the endtime slot, whose correct value is 5:15PM at the 8:45AM slot on the selection view. When the binding event is called a second time, the timeviews for both RTPs are correctly shown, going from 8:30AM to 5:15PM. HTML markup of the RTPs in question as follows, as well as the code-behind for the binding event.

//HTML//
<telerik:RadTimePicker ID="tpStartTime" runat="server" EnableTyping="false" TimeView-Columns="4" TimeView-Interval="00:15:00" Enabled="false"></telerik:RadTimePicker>
<telerik:RadTimePicker ID="tpEndTime" runat="server" EnableTyping="false" TimeView-Columns="4" TimeView-Interval="00:15:00" Enabled="false"></telerik:RadTimePicker>
 
//C#//
protected void dpOriginalDate_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
    {
        DateTime[] shift = getShift((DateTime)dpOriginalDate.SelectedDate);
        tpStartTime.Enabled = tpEndTime.Enabled = true;
        tpStartTime.TimeView.StartTime = shift[0].TimeOfDay;
        tpStartTime.TimeView.EndTime = shift[1].TimeOfDay;
        tpEndTime.TimeView.StartTime = shift[0].AddMinutes(15).TimeOfDay;
        tpEndTime.TimeView.EndTime = shift[1].AddMinutes(15).TimeOfDay;
    }

 

Page_Load contains Page.DataBind(); which appears to be the cause. Do I have to do without it or is there a workaround?

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 19 Jun 2017, 12:17 PM
Hello Jackie,

Calling some general binding commands like Page.DataBind() or Panel1.DataBind() is not a good practice. You could call that these methods to individual controls like RadComboBox or RadListBox. Complex data vizualization controls like RadGrid, RadListView and RadPivotGrid should be bound using their built-in NeedDataSource event handler.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jackie
Top achievements
Rank 1
answered on 19 Jun 2017, 12:37 PM
The purpose of the Page.DataBind() was to make the MinDate set in the HTML front end actually work. I have moved it to the code behind to get around the problem.
0
Eyup
Telerik team
answered on 22 Jun 2017, 10:25 AM
Hello Jackie,

Some properties require to be set earlier in the page life cycle. You can do that during Page_Init event handler.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
DateTimePicker
Asked by
Jackie
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Jackie
Top achievements
Rank 1
Share this question
or