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

timepicker from database

5 Answers 179 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
pandu
Top achievements
Rank 1
pandu asked on 11 Mar 2009, 02:38 PM
can i get the time picker values from database than fixing it Start, end and intervals

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 11 Mar 2009, 02:53 PM
Hello Pandu,

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.
0
pandu
Top achievements
Rank 1
answered on 11 Mar 2009, 06:47 PM
I belive, I was not clear on my question.

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..
0
Daniel
Telerik team
answered on 12 Mar 2009, 02:15 PM
Pandu,

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 ObjectByVal 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.
0
pandu
Top achievements
Rank 1
answered on 12 Mar 2009, 06:54 PM
thanks Daniel..
 
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...

0
Daniel
Telerik team
answered on 17 Mar 2009, 01:07 PM
Hello Pandu,

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.
Tags
Calendar
Asked by
pandu
Top achievements
Rank 1
Answers by
Daniel
Telerik team
pandu
Top achievements
Rank 1
Share this question
or