Assigning Time value to SelectedDate

3 posts, 0 answers
  1. Bill
    Bill avatar
    175 posts
    Member since:
    Apr 2010

    Posted 13 Jan 2011 Link to this post

    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. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Jan 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bill
    Bill avatar
    175 posts
    Member since:
    Apr 2010

    Posted 14 Jan 2011 Link to this post

    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);

     

Back to Top