我们能以某种方式应用这个格式吗?
[Display(Name = "Date of Birthday")]
[DataType(DataType.Date)]
public DateTime DOB { get; set; }
我只想看到日期,不需要时间。
谢谢!
[Display(Name = "Date of Birthday")]
[DataType(DataType.Date)]
public DateTime DOB { get; set; }
我只想看到日期,不需要时间。
谢谢!
您可以使用DisplayFormatAttribute
该属性指定了ASP.NET动态数据如何显示和格式化数据字段。
[DisplayFormat(DataFormatString = "{0:dd MMM yyyy}")]
[Display(Name = "Date of Birthday")]
[DataType(DataType.Date)]
public DateTime DOB { get; set; }
ApplyFormatInEditMode = true
和[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
添加进去。 - nomail