help with calendar control and time picker

4 posts, 1 answers
  1. Kevin
    Kevin avatar
    58 posts
    Member since:
    May 2009

    Posted 05 Jun 2009 Link to this post

    Hi
    This may sound stupid but i need to add a date and time to a database and am using the calendar control and the time picker as the time slots we are using are at 2 hr intervals ho do i pull the date out of the calender and the time out of the time picker and put the 2 together?

    Many thanks
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Jun 2009 Link to this post

    Hi Kevin,

    Try the code below to combine the Date and Time values in to a single DateTime object.

    ASPX:
     
    <telerik:RadCalendar ID="RadCalendar1" runat="server" EnableMultiSelect="False">  
    </telerik:RadCalendar> 
    <telerik:RadTimePicker ID="RadTimePicker1" runat="server">  
    </telerik:RadTimePicker> 

    CS:
     
    protected void Button1_Click(object sender, EventArgs e)  
    {  
        string[] time = RadTimePicker1.SelectedDate.ToString().Trim().Split(' ');  
        string[] date = RadCalendar1.SelectedDate.ToString().Trim().Split(' ');  
        string datetime = date[0] + " " + time[1] + time[2];  
        DateTime DateTimeValue = DateTime.Parse(datetime);  
        Response.Write(DateTimeValue.ToString());  
        // Update database with DateTimeValue.  

    -Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kevin
    Kevin avatar
    58 posts
    Member since:
    May 2009

    Posted 09 Jun 2009 Link to this post

    thanks that has sorted my issue
  5. Jim
    Jim avatar
    15 posts
    Member since:
    Oct 2012

    Posted 24 May 2012 Link to this post

    DateTime finalDateTime = DateTime.Parse(Strings.Format(PrefDate.SelectedDate, "Short Date") + " " + Strings.Format(PreTime.SelectedDate, "Short Time"));
Back to Top