【发布时间】:2020-02-15 09:28:38
【问题描述】:
我想在 editorfor 字段中显示数据库中的值,但它保持空白。该值存在于值字段中,但不显示在页面中。
如果我使用以下解决方案:
Display a formatted date in an EditorFor()
@Html.TextBoxFor(m => m.Van, new { @Value = model.Van.ToString("yyyy/MM/dd"), @class="datepicker" })
我得到了值,但没有得到 EditorFor 字段默认提供的日期选择器。
型号:
[Required]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}", ApplyFormatInEditMode = true)]
public DateTime Van{ get; set; }
查看:
@Html.EditorFor(model => model.Van, new { htmlAttributes = new { @class = "form-control" } })
【问题讨论】:
-
你在使用 Jquery 日期选择器吗?
标签: html entity-framework asp.net-mvc-4