我的模特
[DataType(DataType.Date, ErrorMessage = "Please enter a valid date in the format MM/dd/yyyy")]
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
[Display(Name = "From Date")]
public DateTime FromDate { get; set; }
我的观点
@Html.EditorFor(model => model.FromDate)
我的Date.cshtml(编辑器模板)
@Html.TextBox("", string.Format("{0:MM/dd/yyyy}", DateTime.Now),
new { @class = "datefield", type = "date" })
我的要求是在这个特定视图上显示数据库值,但每次它都显示当前日期。如何做到这一点请帮助我。