This is a migrated thread and some comments may be shown as answers.
Assigning Time value to SelectedDate
2 Answers 25 Views
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 2
Bill asked on 13 Jan 2011, 10:25 PM
How can I assign a time value (AdmitTime - retrieved from a database as a Time field) to the selecteddate property of a RadTimePicker control?

I don't know how to finish the below code retrieved successfully from a LINQ query:
radAdmitTime.SelectedDate = query.AdmitTime.

I am using version 2009.3.1314.35 of the Telerik tools.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 14 Jan 2011, 10:04 AM
Hello William,

I am not quite sure about the issue and one suggestion is to typecast the retrieved value to DateTime  and then assign that  to the radAdmitTime.SelectedDate. Sample code given below.

C#:
protected void Page_Load(object sender, EventArgs e)
  {
 
   DateTime dt = new DateTime(2011, 01, 01, 12, 00, 00);
    ddlTravelStart.SelectedDate = dt;
    
  }

Thanks,
Shinu.
0
Bill
Top achievements
Rank 2
answered on 15 Jan 2011, 02:45 AM
This is what I was looking for which works fine....

 

TimeSpan admitTime = (TimeSpan)query.AdmitTime.Value;

 

radAdmitTime.SelectedDate =

Convert.ToDateTime(admitTime.Hours + ":" + admitTime.Minutes + ":" + admitTime.Seconds);

 

Asked by
Bill
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 1
Bill
Top achievements
Rank 2
Share this question
or