我不想在显示日期时显示年份。我可以使用
DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}"
要这样做吗?显示方式如下:
@Html.DisplayNameFor(model => model.Birthday
感谢EB。
@model MVC
.Models.Employee
@{
ViewBag.Title = "Details";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Details</h2>
<div>
<h4>Employee</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Birthday)
</dt>
<dd>
@Html.DisplayFor(model => model.Birthday)
</dd>
<dd>
<img src="/Employees/RetrieveImage/@Model.ID" />
</dd>
</dl>
</div>
<p>
@Html.ActionLink("Edit", "Edit", new { id = Model.ID }) |
@Html.ActionLink("Delete", "Delete", new { id = Model.ID }) |
@Html.ActionLink("Back to List", "Employees")
</p>