剑道日期选择器不保留正确的日期



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

ViewModel代码:

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
    }

请浏览下面给出的链接。对于您正在解决的问题,它确实有几个解决方案。如果问题仍然存在,请恢复。

从剑道UI到ASP的传递日期。NET MVC

相关内容

  • 没有找到相关文章

最新更新