picking time only results in date changing to today's date?

2 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    14 posts
    Member since:
    Feb 2011

    Posted 12 Oct 2011 Link to this post

    We're currently using an ASCX page as the edit template for a grid. We have some dates and times in the grid, but in this particular grid we want to allow the user to change the time but not change the date when editing an existing item. We use a label to display the date, and a RadTimePicker to display the time.

    The problem is, whenever the user edits the time, the date is changing to today's date rather than maintaining the original date and only changing the time. Below is the definition of the control. Is our definition of the control missing something that would cause it to keep the date stored? Do RadTimePickers not store the date at all and I need to find some way of concatenating the results?

    Below is the definition for one of these label-radtimepicker pairs.

    <asp:Label id="txtDateIn" runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.DateIn","{0:MM/dd/yy}") %>' Width="48px" />
                            <telerik:RadTimePicker ID="RadDateTimePicker3" EnableEmbeddedSkins="false" Skin="UCP_Vista" Width="85px" DbSelectedDate='<%# DataBinder.Eval( Container, "DataItem.DateIn")%>' runat="server">
                                <TimeView ID="TimeView1" runat="server" Interval="00:15:00" Columns="6" EnableEmbeddedSkins="false" Skin="UCP_Vista" ShowHeader="false" />
                                <DateInput ID="DateInput1" runat="server" Font-Size="11px" Font-Bold="true" ForeColor="#396F96" CssClass="itemt" />
                            </telerik:RadTimePicker>

    I didn't see a forum for the date/time pickers, so if I missed one this belongs in, please feel free to move it to the correct forum.
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 17 Oct 2011 Link to this post

    Hello Jonathan,

    RadTimePicker can be used to select time, but it will return the current date, because internally it uses DateTime object which can't hold null date.
    After the user selection, you could construct new DateTime object with date from your label and time from the TimePicker similar to how is done in this forum thread:
    http://www.telerik.com/community/forums/aspnet-ajax/calendar/raddatepicker-and-radtimepicker-to-use-same-date.aspx

    Greetings,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top