Html.DisplayFor
停止顯示顯示名稱和格式化的字符串...我的代碼是波紋管...任何想法?我搜查周圍任何找不到任何東西。感謝asp.net mvc 5 html.DisplayFor DisplayFormat顯示(名稱)不起作用
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
[Display(Name = "Date")]
public DateTime EventDateTimeDay { get; set; }
[Display(Name = "Seconds")]
[DisplayFormat(DataFormatString = "{0:0.00} s")]
public double Duration { get; set; }
剃刀.cshtml:
@model IEnumerable<OurClass>
...
<th>
@Html.DisplayNameFor(model => model.EventDateTimeDay)
</th>
...
@foreach (var item in Model)
{
...
<td>
@Html.DisplayFor(modelItem => item.EventDateTimeDay)
</td>
是也試過,這是行不通的。感謝您的迴應。它並不能解釋爲什麼DisplayFormat不起作用。 – dan
看起來像這個已經在另一篇文章中回答了[鏈接] http://stackoverflow.com/questions/15976576/mvc-and-entity-framework-html-displaynamefor-with-composite-viewmodel [/ link] – user1440815