Datetime 可为空的日期时间和空日期仍显示为1/1/0001

Datetime 可为空的日期时间和空日期仍显示为1/1/0001,datetime,jqgrid,asp.net-mvc-4,nullable,Datetime,Jqgrid,Asp.net Mvc 4,Nullable,在我的jqGrid中,我希望在我的网格中有空值 相反,我得到的是1/1/0001 dateTime的模型类型都可以为空 我错过什么了吗 这是代码 public DateTime? DischargeDateTime { get; set; } 你们推荐什么 tableToGrid("#frTable", { cmTemplate: { sortable: false }, caption: '@TempData["POPNAME"

在我的jqGrid中,我希望在我的网格中有空值

相反,我得到的是1/1/0001

dateTime的模型类型都可以为空

我错过什么了吗

这是代码

public DateTime? DischargeDateTime { get; set; }
你们推荐什么

        tableToGrid("#frTable", {
            cmTemplate: { sortable: false },
            caption: '@TempData["POPNAME"]' + ' Population',
            height: '400',
            gridview: true,
            shrinkToFit: false,
            autowidth: true,
            colNames: ['Edit',
                   'MRN',
                   'Hospital Fin',
                   'First Name',
                   'Last Name',
                   'Date of birth',
                   'Completed Pathway',
                   'Completed Pathway Reason',
                   'PCP Appointment',
                   'Specialist Appointment',
                   'Admit Date',
                   'Discharge Date',
                   'Discharge Disposition',
                   'Discharge To',
                   'Discharge Advocate Call',
                   'Home Healthcare',
                   'Safe Landing Accepted',
                   'PCP Name',
                   'PCP Phone',
                   'PCP Appointment Location',
                   'Specialist Name',
                   'Specialist Phone',
                   'Specialist Appointment Location',
                   'Comments',
                   'Patient Room Phone',
                   'Phone',
                   'Payor',
                   'MRN Type'
                   ],
            colModel: [
                   { name: 'Edit', width: 95, align: 'left' },
                   { name: 'MRN', width: 125, align: 'left' },
                   { name: 'Hospital_Fin', width: 145, align: 'left' },
                   { name: 'First_Name', width: 115, align: 'left' },
                   { name: 'Last_Name', width: 115, align: 'left' },
                   { name: 'Date_of_birth', width: 145, align: 'left' },
                   { name: 'Completed_Pathway', width: 125, align: 'left', editOptions: {value:"1:Yes;0:No"} },
                   { name: 'Completed_Pathway_Reason', width: 165, align: 'left' },
                   { name: 'PCP_Appointment', width: 115, align: 'left' },
                   { name: 'Specialist_Appointment', width: 125, align: 'left' },
                   { name: 'Admit_Date', width: 185, align: 'left' },
                   { name: 'Discharge_Date', width: 185, align: 'left' },
                   { name: 'Discharge_Disposition', width: 155, align: 'left' },
                   { name: 'Discharge_To', width: 85, align: 'left' },
                   { name: 'Discharge_Advocate_Call', width: 155, align: 'left' },
                   { name: 'Home_Health_Care_Accepted', width: 105, align: 'left' },
                   { name: 'Safe_Landing_Accepted', width: 165, align: 'left' },
                   { name: 'PCP_Name', width: 85, align: 'left' },
                   { name: 'PCP_Phone', width: 85, align: 'left' }, // formatter: formatPhoneNumber,
                   { name: 'PCP_Appointment_Location', width: 185, align: 'left' },
                   { name: 'Specialist_Name', width: 195, align: 'left' },
                   { name: 'Specialist_Phone', width: 135, align: 'left' }, //, formatter: formatPhoneNumber
                   { name: 'Specialist_Appointment_Location', width: 185, align: 'left' },
                   { name: 'Comments', width: 185, align: 'left' },
                   { name: 'Patient_Room_Phone', width: 135, align: 'left' }, //, formatter: formatPhoneNumber
                   { name: 'Phone', width: 125, align: 'left' }, //, formatter: formatPhoneNumber
                   { name: 'Payor', width: 155, align: 'left' },
                   { name: 'MRN_Type', width: 135, align: 'left' }
                   ]
        });
我的数据库中确实有几个空值返回。。。不知道为什么这不起作用

当前正在尝试UIHint

@if (Model == null){
    <text></text>
}else{
    <text></text>
}
@if(Model==null){
}否则{
}

但现在所有内容都显示不正确

正常。。。我知道我做错了什么。在我的存储库层中,我忘记了我有一个方法,该方法将获取正在进行打包、解析的字符串日期,如果该值为null,我将设置最小日期

我现在已经改变了,所以它返回一个空值,或者一个解析的日期

    public static DateTime? ValueOrMin(string value)
    {
        if (string.IsNullOrWhiteSpace(value)) return null;
        return DateTime.Parse(value);
    }

谢谢。

你能再发一点内容吗?如何为网格填充和序列化模型,jqGrid设置的相关部分是什么样子的?你签入fiddler/firebug了吗?你从服务器上得到了什么数据?我知道我从服务器上得到了一些空的或空的日期。。。我将发布我的jqGrid设置。。。这是一个tableToGrid调用。。。