Retrieving values from RadDatetimpicker dateinput control within an EditItemTemplate

4 posts, 0 answers
  1. Riaan
    Riaan avatar
    17 posts
    Member since:
    Jan 2009

    Posted 11 Mar 2009 Link to this post

    Hallo,

    I am having trouble retrieving the updated time value that users enter into my dateinput control of my raddatetimepicker that is within an EditItemTemplate in my Radgrid. On server side the values are persisting, meaning that they  are the same values that loaded when the grid loaded originally, I have also tried swithing off EnableViewState and I have also tried an Editmanager.

    Could you please provide met with further ideas about what to do next? Below is aspx snippet and c# snippet. Thank you.

    <ItemTemplate>  
    <telerik:RadDateTimePicker ID="rdtpStartingTimeData" Enabled="false" runat="server" Calendar-DatePopupButton-Visible="false" DatePopupButton-Visible="false"                                                     SelectedDate='<%# DataBinder.Eval(Container, "DataItem.TimeStart") %>' DateInput-DateFormat="hh:mm" Culture="English (South Africa)" TimeView-TimeFormat="HH:mm" TimeView-Columns="4">  
    </telerik:RadDateTimePicker>  
    </ItemTemplate>  
    <EditItemTemplate>  
    <telerik:RadDateTimePicker ID="rdtpStartingTime" runat="server" Calendar-DatePopupButton-Visible="false" DatePopupButton-Visible="false" EnableViewState="false" DateInput-Visible="true" SelectedDate='<%# DataBinder.Eval(Container,"DataItem.TimeStart") %>' DateInput-DateFormat="hh:mm" Culture="English (South Africa)" TimeView-TimeFormat="HH:mm" TimeView-Columns="4">  
    </EditItemTemplate>  
    </telerik:GridTemplateColumn> 

     if (e.CommandName == Telerik.Web.UI.RadGrid.UpdateCommandName)  
                {  
                    Telerik.Web.UI.GridEditableItem editedItem = e.Item as Telerik.Web.UI.GridEditableItem;  
     
                    Telerik.Web.UI.RadDateTimePicker rdtpStartTime = (Telerik.Web.UI.RadDateTimePicker)editedItem.FindControl("rdtpStartingTime");  
                    Telerik.Web.UI.RadDateTimePicker rdtpEndTime = (Telerik.Web.UI.RadDateTimePicker)editedItem.FindControl("rdtpEndingTime");  
                }  
     

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Mar 2009 Link to this post

    Hello Riaan,

    You can try out the following code to retrieve the updated time value from the RadDateTimePicker:
    cs:
    protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) 
        { 
             GridEditableItem editItem = (GridEditableItem)e.Item; 
             RadDateTimePicker dateTimePicker = (RadDateTimePicker)editItem.FindControl("rdtpStartingTime"); 
             DateTime date = Convert.ToDateTime(dateTimePicker.SelectedDate); 
        } 

    Thanks
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Riaan
    Riaan avatar
    17 posts
    Member since:
    Jan 2009

    Posted 11 Mar 2009 Link to this post

    Hi Princy, thanks for the reply.

    I am aware of the selecteddate property, the problem is that the datetime that I do get from the control is the original datetime, and not the new value the user has selected or entered. 

  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 Mar 2009 Link to this post

    Hi Riaan,

    I used the above code to access the new time value('8:00') I entered in the DateTimePicker, on the UpdateCommand. The old value of the DateTimePicker was '10:00'. In code behind, the date variable was found equal to 3/12/2009 10:00:00 AM. Also I used version 2008.1.415.20.

    If at all you want to access only the time, then you can use a RadTimePicker instead of RadDateTimePicker.

    -Princy.
Back to Top