Hi, Im trying to build a table that has 2 datetimes on it.
My problem is just that, on the method UpdateContainer, the instance container has the default date and never get updated .
Here is my front code:
@(Html.Kendo().Grid<WebPruebaTelerik1.Models.Container>() .Name("ContainersStorage") .Columns(columns => { columns.Bound(p => p.Id).Title("ID").Width(150).Locked(true); columns.Bound(p => p.Number).Title("Número").Width(150); columns.Bound(p => p.Source).Title("Origen").Width(150); columns.Bound(p => p.Type).Title("Tipo").Width(150); columns.Bound(p => p.Material).Title("Material").Width(150); columns.Bound(p => p.Gas).Title("Gas").Width(150); columns.Bound(p => p.ConstructionDate).Title("Fecha de Fabricación").Format("{0: yyyy-MM-dd HH:mm:ss}").Width(250); columns.Bound(p => p.InspectionDate).Title("Fecha de Inspección").Format("{0: yyyy-MM-dd HH:mm:ss}").Width(250); columns.Bound(p => p.ACEP).Title("ACEP").Width(150); columns.Bound(p => p.Tara).Title("Tara").Width(150); columns.Bound(p => p.MGW).Title("MGW").Width(150); columns.Bound(p => p.Trust).Title("Confianza").Width(150); columns.Command(command => { command.Edit(); command.Destroy(); }).Width(150); }) .ToolBar(toolbar => toolbar.Create()) .Resizable(resizable => resizable.Columns(true)) .Scrollable(scrollable => scrollable.Height(540)) .Editable(editable => editable.Mode(GridEditMode.InLine)) .Pageable() .Sortable() .HtmlAttributes(new { style = "height:550px;" }) .Filterable() .Events(events => events.Save("saveContainers")) .DataSource(dataSource => dataSource .Ajax() .PageSize(10) .Read("ListContainer", "Home") .Model(model => model.Id(p => p.Id)) .Update("UpdateContainer", "Home") .Create("CreateContainer", "Home") .Destroy("DeleteContainer", "Home") ) )
Here is my controller code :
public class HomeController : Controller{ [HttpPost] public ActionResult UpdateContainer([DataSourceRequest] DataSourceRequest request, Container container) { dao.EditContainer(container); //Here has a breakpoint return Json(new[] { container }.ToDataSourceResult(request, ModelState)); }}public class Container { public int Id { get; set; } public int Number { get; set; } public int Source { get; set; } public int Type { get; set; } public int Material { get; set; } public int Gas { get; set; } [DataType(DataType.DateTime)] public DateTime ConstructionDate { get; set; } = new DateTime(1970, 1, 1); [DataType(DataType.DateTime)] public DateTime InspectionDate { get; set; } = new DateTime(1970, 1, 1); public string ACEP { get; set; } = ""; public float Tara { get; set; } public float MGW { get; set; } public int Trust { get; set; } }