RadTimePicker in RadGrid problem

2 posts, 0 answers
  1. Ken
    Ken avatar
    1 posts
    Member since:
    Jul 2008

    Posted 06 Jan 2009 Link to this post


    I am using a RadTimePicker template column in a radgrid (both are RadControls for ASP.NET Q2 2008). I initialized StartTime and EndTime for the time pickers, but it does not take effect in the client side - the picker still displays time range from 12:00AM to 23:30. Here is the ASP page (there is only one radgrid control on the page):

    <rad:radgrid id="gdActivityTime" runat="server" skin="Office2007" Autogeneratecolumns="false" width="95%">

             <MasterTableView DataKeyNames="ActivityNodeID" ShowHeader="false">

            <rad:GridBoundColumn DataField="ActivityName" HeaderText="Activity"></rad:GridBoundColumn>


                       <rad:RadTimePicker AutoPostBack="true" ID="pkDesignatedStartTime" runat="server" Width="85px" >
                           <TimeView ID="TimeView1" runat="server"  Skin="" Interval="0:30">
                           <PopupButton Visible="False" />
                           <DatePopupButton Visible="False" />
                           <DateInput Skin="" />

    Here is the code behind:

    //generate 10 rows:
    DataTable tblActTime = new DataTable();
    tblActTime.Columns.Add(new DataColumn("ActivityName", typeof(string)));
    tblActTime.Columns.Add(new DataColumn("DesignatedStartTime", typeof(TimeSpan)));
    tblActTime.Columns.Add(new DataColumn("ActivityNodeID", typeof(string)));

    for(int n=0; n<10; n++)
       DataRow dract = tblActTime.NewRow();
       dract["ActivityName"] = string.Format("Activity{0}", n);
       dract["ActivityNodeID"] = n;

    gdActivityTime.DataSource = tblActTime;

    //initialize start/end time for all time picker in the grid:

    TimeSpan dtStart = new TimeSpan(0, 8, 0);
    TimeSpan dtEnd = new TimeSpan(0, 21, 0);

    foreach (GridDataItem pkgItem in gdActivityTime.MasterTableView.Items)
        DataRowView drx = pkgItem.DataItem as DataRowView;
        RadTimePicker dp = pkgItem.FindControl("pkDesignatedStartTime") as RadTimePicker;
        dp.TimeView.StartTime = dtStart;
        dp.TimeView.EndTime = dtEnd;

    Thank you in advance.


  2. Pavel
    Pavel avatar
    904 posts

    Posted 09 Jan 2009 Link to this post

    Hello Ken,

    I just tested this with the latest versions of our controls and it is working as expected. Please find attached a runnable sample created based on the code and markup you pasted.

    Kind regards,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top