我的视图模型: public partial class FileTransferFilterCriteriaViewModel{ public string Fice { get; set; } public string SourceEmail { get; set; } public string TargetEmail { get; set; } public DateTime FromDate { get; set; } public D
public partial class FileTransferFilterCriteriaViewModel { public string Fice { get; set; } public string SourceEmail { get; set; } public string TargetEmail { get; set; } public DateTime FromDate { get; set; } public DateTime ToDate { get; set; } public string Status { get; set; } public string Category { get; set; } }
(没有任何东西来自数据库.)
我的控制器:
return View(new FileTransferFilterCriteriaViewModel())
以下是FromDate和ToDate的显示内容:
1/1/0001 12:00:00 AM
我的HTML:
@Html.TextBoxFor(x =>x.Criteria.FromDate)
问题:
>如果日期为空,如何禁止显示默认日期值?
>如果日期不为空,我如何将日期格式化为MM / dd / yyyy?
public DateTime? FromDate { get; set; }