我添加了属性,但这是不工作的,我的期望。02052020 04: 10 AM结果: 02052020 04: 10: 25
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:g}")]
来自 正式文件如果在没有其他自定义格式指定符的情况下使用 "g "格式指定符,则解释为 "g" 标准日期和时间格式指定器 这是以文化为基础的。
对于日期格式 02052020 04:10 AM 你可以像下面这样设置DataFormatString。
[DisplayFormat(ApplyFormatInEditMode=true,DataFormatString = "{0:dd/MM/yyyy/h:m tt}")]