This is a migrated thread and some comments may be shown as answers.

Retrieving values from RadDatetimpicker dateinput control within an EditItemTemplate

3 Answers 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Riaan
Top achievements
Rank 1
Riaan asked on 11 Mar 2009, 08:03 AM

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

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Mar 2009, 11:35 AM
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.
0
Riaan
Top achievements
Rank 1
answered on 11 Mar 2009, 11:51 AM

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. 

0
Princy
Top achievements
Rank 2
answered on 12 Mar 2009, 10:19 AM
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.
Tags
Grid
Asked by
Riaan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Riaan
Top achievements
Rank 1
Share this question
or