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

RadTimePicker.SelectedTime is Nothing in RadGrid Edit Template upon Update

3 Answers 99 Views
TimePicker
This is a migrated thread and some comments may be shown as answers.
Timothy
Top achievements
Rank 1
Timothy asked on 31 Aug 2016, 07:19 PM

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

Thanks!

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">
                <Columns>
                    <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column" HeaderText="Pick Time" UniqueName="PickTime"  HeaderStyle-Width="100px">
                        <EditItemTemplate>
                            <telerik:RadTimePicker ID="RadTimePicker1" runat="server" Skin="Default" Width="88px">
                            </telerik:RadTimePicker>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server"></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridEditCommandColumn>
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn UniqueName="Group" DataField="Group" HeaderText="Group" ReadOnly="True">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn UniqueName="Payroll" DataField="Payroll #" HeaderText="Payroll #" ReadOnly="True">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn UniqueName="LastName" DataField="Last Name" HeaderText="Last Name" ReadOnly="True">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn UniqueName="FirstName" DataField="First Name" HeaderText="First Name" ReadOnly="True">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn UniqueName="MI" DataField="MI" HeaderText="MI" ReadOnly="True">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn UniqueName="SeniorDate" DataField="Senior Date" HeaderText="Senior Date" ReadOnly="True">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn UniqueName="Sequence" DataField="Seq" HeaderText="Sequence" ReadOnly="True">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn UniqueName="DeptLoc" DataField="Dept #/ Location" HeaderText="Dept/Location" ReadOnly="True">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn UniqueName="JobCode" DataField="Job Code" HeaderText="Job Code" ReadOnly="True">
                    </telerik:GridBoundColumn>
                </Columns>
 
                <EditFormSettings>
                    <EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
                </EditFormSettings>
            </MasterTableView>
 
            <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>
            </ClientSettings>
 
            <HeaderStyle Font-Size="Small" Font-Bold="True"></HeaderStyle>
 
            <ItemStyle Font-Size="Small"></ItemStyle>
 
            <FilterMenu RenderMode="Lightweight"></FilterMenu>
 
            <HeaderContextMenu RenderMode="Lightweight"></HeaderContextMenu>
        </telerik:RadGrid>

RadGrid_UpdateCommand:

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

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 05 Sep 2016, 12:52 PM
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.

Regards,
Eyup
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.
0
Timothy
Top achievements
Rank 1
answered on 06 Sep 2016, 03:50 PM
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.
0
Timothy
Top achievements
Rank 1
answered on 06 Sep 2016, 04:38 PM
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.
Tags
TimePicker
Asked by
Timothy
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Timothy
Top achievements
Rank 1
Share this question
or