数据类型(DataType.Date)格式(MVC) [英] DataType(DataType.Date) format (MVC)
本文介绍了数据类型(DataType.Date)格式(MVC)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以将某种方式的格式呢?
Can we apply somehow the format for this?
[Display(Name = "Date of Birthday")]
[DataType(DataType.Date)]
public DateTime DOB { get; set; }
我想看到的只有日期,而不是时间。
I'd like to see only Date and not Time.
感谢您!
推荐答案
您可以使用的 DisplayFormatAttribute 的
指定如何数据字段的显示和格式由ASP.NET动态数据。
Specifies how data fields are displayed and formatted by ASP.NET Dynamic Data.
<一个href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displayformatattribute.aspx">http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displayformatattribute.aspx
[DisplayFormat(DataFormatString = "{0:dd MMM yyyy}")]
[Display(Name = "Date of Birthday")]
[DataType(DataType.Date)]
public DateTime DOB { get; set; }
这篇关于数据类型(DataType.Date)格式(MVC)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文