Binding a RadDateTimePicker to a data source is easy provided you use the DbSelectedDate property (in a similar way as with the RadDatePicker control).
This example demonstrates binding RadDateTimePicker control which is in a RadGrid template column:
<EditItemTemplate> <telerik:RadDateTimePicker ID="picker1" runat="server" DbSelectedDate='<%# Bind("Dates") %>'> </telerik:RadDateTimePicker> </EditItemTemplate>
The second Grid in the presented example benefits from the GridDateTimeColumn option so that the markup/code is highly optimized. The GridDateTimeColumn's RadDateTimePicker uses a "shared" calendar and TimeView internally.
When you want to bind RadTimePicker to TimeSpan you need to set UseTimeSpanForBinding="true". This will make the DbSelectedDate to return TimeSpan instead of DateTime object. For GridDateTimeColumn this is automatically set if you use PickerType="TimePicker" and DataType="System.TimeSpan"
<telerik:RadTimePicker UseTimeSpanForBinding="true" ID="picker2" runat="server" DbSelectedDate='<%# Bind("Times") %>' > </telerik:RadTimePicker>
The demo illustrates how datetime pickers with shared calendars/time views can be used either as part of built-in RadGrid GridDateTimeColumn or inside an edit template of a GridTemplateColumn. The second approach can be used for other data-bound controls (repeaters, data lists, etc.) as well. Additionally, the DbSelectedDate property of RadDateTimePicker is of nullable type and hence supports null values.