以下是我在“细节”视图中正在处理的项目的示例。现在如果说明的值为空,则不显示任何内容。
<div class="display-field"> @Html.displayFor(model => model.Description) </div>
[display(Name = "Last connection")] [displayFormat(NulldisplayText = "Never connected")] public DateTime? last_connection { get; set; }
那么在你看来:
@Html.displayFor(x => x.last_connection)