我想根据 Tempdata 设置值,但它没有显示。我存储的 TempData 值是“2012-09-28”。我在下面进行了测试,但它没有显示在日期选择器中:
模型.cs
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
[DataType(DataType.Date)]
public Nullable<DateTime> bookDate{ get; set; }
我的页面.cshtml
@Html.EditorFor(m => m.myModel.bookDate, new { @Value = "2012-09-28", htmlAttributes = new { @class = "form-control"} })
@Html.EditorFor(m => m.myModel.bookDate, new { @Value = TempData["myDate"], htmlAttributes = new { @class = "form-control"} })