I am using a grid to edit a model a StarDate and EndDate defined as DateTime. The grid is Ajax-bound and uses in-line editing. If I try to edit (or add) a record, the grid correctly displays the dates using the Telerik DateTime editor template. I am wiring up some javascript to intercept the save event. The save event gets invoked. The issue is that e.values does not contain any entries for the DateTime properties - all the other properties get passed correctly. If I use a Date type instead (decorating the property with [DataType(DataType.Date)]) in the model) everything works fine and the value gets passed down correctly. If I disable the DateTime editor template and use a standard text box, everything works fine.
Is there something that needs to be done to the DateTime editor template to make it work properly with javascript?
Here is the code I have for the DateTime editor template:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<
DateTime
?>" %>
<%@ Import Namespace="Telerik.Web.Mvc.UI" %>
<%= Html.Telerik().DateTimePicker()
.Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
.Value(Model > DateTime.MinValue? Model : DateTime.Today)
%>
Model:
public class CouponModel
{
[HiddenInput(DisplayValue = false)]
public int CouponId { get; set; }
public DateTime StartDate { get; set; }
[DataType(DataType.Date)]
public DateTime EndDate { get; set; }
}
Javascript OnSave():
function onSourceCodeSaleRulesGridSave(e) {
var values = e.values;
alert(values['Section.StartDate']); // This is undefined
alert(values['Section.EndDate']); // This works
}
Note that I use MVC3 with Razor.
Thanks in advance for your help.