Kendo 日期选择器没有保留正确的日期

Kendo date picker doesn't retain correct date

我有一个包含 2 个日期字段的 KendoGrid。两个日期都显示为读取传输传递的正确初始值。但是,如果用户编辑任一日期然后单击 "Update",更新传输将收到默认的 date/time 值 {1/1/0001 12:00:00 AM}。用户更改的所有其他数据都是正确的,但日期都设置为 {1/1/0001 12:00:00 AM} 而不是用户选择的日期。

视图模型代码:

public class CampaignViewModel
{       
    public int CampaignID { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
}

查看代码:

    var ds = new kendo.data.DataSource({
    transport: 
        {
            read:
                {
                    url: "/Campaign/ReadCampaigns/",
                    dataType: "json"
                },
            create:
                {
                    url: "/Campaign/AddCampaign/",
                    type: "post",
                    dataType: "json"
                },
            update: 
                {
                    url: "/Campaign/UpdateCampaign",
                    type: "POST",
                    dataType: "json"
                }
        },
    batch: false,        
    schema:
    {
        model:
        {
            id: "CampaignID",
            fields:
            {
                id: { type: "number", editable: false },
                Name: { type: "string" },
                Descirption: { type: "string" },
                StartDate: { type: "date" },
                EndDate: { type: "date" }
            }
        }
    }
});

控制器代码:

    public string ReadCampaigns()
    {
        This code seems to be working fine. all dates are passed to view correctly and the dates show correctly in the kendo date pickers.
    }

    [HttpPost]
    public JsonResult AddCampaign(CampaignViewModel data)
    {
        all CampaignViewModel date fields are set to {1/1/0001 12:00:00 AM} for some reason
    }

    [HttpPost]
    public JsonResult UpdateCampaign(CampaignViewModel data)
    {
        all CampaignViewModel date fields are set to {1/1/0001 12:00:00 AM} for some reason
    }

请仔细阅读下面给出的link。对于您要解决的问题,它确实有几个解决方案。如果问题仍然存在,请回复。

Passing dates from Kendo UI to ASP.NET MVC