5 Answers, 1 is accepted
Have a look at this demo:
RadTimePicker Data binding
This link would also be helpful.
Data Binding documentation
Regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
the time picker POPUP values (7.00, 9.00, 9.30, 10.00 etc..), I would like to display values from the data base.. instead of Design time values using start time, interval and end time..
Can I do that??
If not, Do we have any list control to display only values from timings and associate back to datatimepicker..
You can bind the nested TimeView to collection of custom objects. I suppose you missed the second link:
aspx:
<h4>Binding to generic list of DateTime</h4> |
<telerik:RadTimePicker ID="RadTimePicker3" Skin="Hay" runat="server" /> |
<br /> |
<h4>Binding to ArrayList of DateTime</h4> |
<telerik:RadTimePicker ID="RadTimePicker4" Skin="Hay" runat="server" /> |
<br /> |
<h4>Binding to DateTime array</h4> |
<telerik:RadTimePicker ID="RadTimePicker5" Skin="Hay" runat="server" /> |
<br /> |
<h4>Binding to object array with DateTime</h4> |
<telerik:RadTimePicker ID="RadTimePicker6" Skin="Hay" runat="server" /> |
C#:
protected void Page_Load(object sender, EventArgs e) |
{ |
List<DateTime> list = new List<DateTime>(); |
list.Add(DateTime.Now); |
list.Add(DateTime.Now.AddHours(1)); |
list.Add(DateTime.Now.AddHours(2)); |
list.Add(DateTime.Now.AddHours(3)); |
RadTimePicker1.TimeView.DataList.DataSource = list; |
ArrayList arrayList = new ArrayList(); |
arrayList.Add(DateTime.Now); |
arrayList.Add(DateTime.Now.AddHours(1)); |
arrayList.Add(DateTime.Now.AddHours(2)); |
arrayList.Add(DateTime.Now.AddHours(3)); |
RadTimePicker2.TimeView.DataList.DataSource = arrayList; |
RadTimePicker3.TimeView.DataList.DataSource = new DateTime[] { DateTime.Now, DateTime.Now.AddHours(1) }; |
RadTimePicker4.TimeView.DataList.DataSource = new object[] { DateTime.Now, DateTime.Now.AddHours(1) }; |
} |
VB.NET:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load |
Dim list As New List(Of DateTime)() |
list.Add(DateTime.Now) |
list.Add(DateTime.Now.AddHours(1)) |
list.Add(DateTime.Now.AddHours(2)) |
list.Add(DateTime.Now.AddHours(3)) |
RadTimePicker1.TimeView.DataList.DataSource = list |
Dim arrayList As New ArrayList() |
arrayList.Add(DateTime.Now) |
arrayList.Add(DateTime.Now.AddHours(1)) |
arrayList.Add(DateTime.Now.AddHours(2)) |
arrayList.Add(DateTime.Now.AddHours(3)) |
RadTimePicker2.TimeView.DataList.DataSource = arrayList |
RadTimePicker3.TimeView.DataList.DataSource = New DateTime() {DateTime.Now, DateTime.Now.AddHours(1)} |
RadTimePicker4.TimeView.DataList.DataSource = New Object() {DateTime.Now, DateTime.Now.AddHours(1)} |
End Sub |
Binding to Custom Collection
Regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I was using my timepicker inside the radgrid control EDIT template--
it throws following error message ----
Unable to cast object of type 'System.DateTime' to type 'System.Data.DataRowView'.
Here is my Radgrid_itemdatabound function..
protected void RadGrid_ItemDataBound(Object sender, Telerik.WebControls.GridItemEventArgs e)
GridDataItem dataItem;
dataItem = (GridDataItem)e.Item;
RadDateTimePicker rad;
rad = (RadDateTimePicker)e.Item.FindControl("RadDateTimePicker_CutOffDate");
if (rad != null)
{
//rad.Calendar.MultiViewColumns = 1;
//rad.Calendar.MultiViewRows = 1;
//rad.TimeView.StartTime = new TimeSpan(12, 0, 0);
//rad.TimeView.Interval = new TimeSpan(0, 180, 0);
//rad.TimeView.EndTime = new TimeSpan(16, 0, 0);
rad.TimeView.DataList.DataSource = new DateTime[] { DateTime.Now, DateTime.Now.AddHours(1) };
//rad.TimeView.DataBind();
}
rad.SelectedDate = Convert.ToDateTime(data["CutOffDateTime"]);
rad.FocusedDate = Convert.ToDateTime(data["CutOffDateTime"]);
Do I need to add any special property to bind the timepicker values to Rad Grid controls...
I'm afraid this functionality is not supported in RadControls for ASP.NET. Please use RadControls for ASP.NET AJAX instead.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.