RadTimePicker.SelectedTime is Nothing in RadGrid Edit Template upon Update

4 posts, 0 answers
  1. Timothy
    Timothy avatar
    10 posts
    Member since:
    Jun 2014

    Posted 31 Aug 2016 Link to this post

    When using a RadTimePicker in a RadGrid (in a EditItemTemplateColumn), I'm getting Nothing for the RadTimePicker.SelectedTime object when updating.  


    Here is my RadGrid:

    <telerik:RadGrid runat="server" ID="grdScheduleBook" AllowSorting="True" AllowPaging="True" PageSize="15" AutoGenerateColumns="False"
                OnNeedDataSource="grdScheduleBook_NeedDataSource" RenderMode="Lightweight" HeaderStyle-Font-Size="X-Small" ItemStyle-Font-Size="X-Small" Height="800px">
                <MasterTableView EditMode="InPlace">
                        <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column" HeaderText="Pick Time" UniqueName="PickTime"  HeaderStyle-Width="100px">
                                <telerik:RadTimePicker ID="RadTimePicker1" runat="server" Skin="Default" Width="88px">
                                <asp:Label ID="Label1" runat="server"></asp:Label>
                        <telerik:GridBoundColumn UniqueName="Group" DataField="Group" HeaderText="Group" ReadOnly="True">
                        <telerik:GridBoundColumn UniqueName="Payroll" DataField="Payroll #" HeaderText="Payroll #" ReadOnly="True">
                        <telerik:GridBoundColumn UniqueName="LastName" DataField="Last Name" HeaderText="Last Name" ReadOnly="True">
                        <telerik:GridBoundColumn UniqueName="FirstName" DataField="First Name" HeaderText="First Name" ReadOnly="True">
                        <telerik:GridBoundColumn UniqueName="MI" DataField="MI" HeaderText="MI" ReadOnly="True">
                        <telerik:GridBoundColumn UniqueName="SeniorDate" DataField="Senior Date" HeaderText="Senior Date" ReadOnly="True">
                        <telerik:GridBoundColumn UniqueName="Sequence" DataField="Seq" HeaderText="Sequence" ReadOnly="True">
                        <telerik:GridBoundColumn UniqueName="DeptLoc" DataField="Dept #/ Location" HeaderText="Dept/Location" ReadOnly="True">
                        <telerik:GridBoundColumn UniqueName="JobCode" DataField="Job Code" HeaderText="Job Code" ReadOnly="True">
                        <EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
                <GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
                <ClientSettings AllowColumnsReorder="True" Resizing-AllowColumnResize="true" ReorderColumnsOnClient="True">
                    <Selecting AllowRowSelect="True" />
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                    <ClientEvents OnBatchEditOpening="OnBatchEditOpening" />
                    <Resizing AllowColumnResize="True"></Resizing>
                <HeaderStyle Font-Size="Small" Font-Bold="True"></HeaderStyle>
                <ItemStyle Font-Size="Small"></ItemStyle>
                <FilterMenu RenderMode="Lightweight"></FilterMenu>
                <HeaderContextMenu RenderMode="Lightweight"></HeaderContextMenu>


    Protected Sub grdScheduleBook_UpdateCommand(sender As Object, e As GridCommandEventArgs) Handles grdScheduleBook.UpdateCommand
            Dim dataItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
            Dim timePicker As RadTimePicker = CType(e.Item.FindControl("RadTimePicker1"), RadTimePicker)
            Dim time As String = timePicker.SelectedTime.ToString()
            Dim row As DataRowView = dataItem.DataItem
            Dim sql As String
            Dim payroll As String = row.Row.ItemArray(1)
            Dim pickTime As String = Format(time.ToString(), "Short Time")
            '...(sql command here)...
    End Sub

  2. Eyup
    Eyup avatar
    3386 posts

    Posted 05 Sep 2016 Link to this post

    Hi Timothy,

    I've created a sample RadGrid web site to demonstrate that picker should pass the selected date as expected. Please run the attached application and verify that it works as expected on your side, too.

    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. Timothy
    Timothy avatar
    10 posts
    Member since:
    Jun 2014

    Posted 06 Sep 2016 in reply to Eyup Link to this post

    That project worked and when debugged, I can see it got the selected time.  So what does the object SelectedTime for RadTimePicker represent if you must use SelectedDate instead to get the time?  Does not make much sense.  Thanks for the help.
  4. Timothy
    Timothy avatar
    10 posts
    Member since:
    Jun 2014

    Posted 06 Sep 2016 Link to this post

    Looks like my whole issue was binding the source of the grid in another call which was causing the SelectedTime to be Nothing.  I can now see the SelectedTime object is being populated properly.  Thanks for the push in the right direction.
Back to Top