【发布时间】:2018-12-05 12:07:31
【问题描述】:
例如我有课
public class Car
{
public string Name { get; set; }
public string Brand { get; set; }
public string Color { get; set; }
}
我有一个模型作为列表的视图
@model IEnumerable<Car>
现在我想显示 listItem(模型)的属性的原始 displayName。
示例代码:
@model IEnumerable<Car>
//(..)
<thead>
<tr>
<th>"[@Html.DisplayName(Model.First().Name))]"</th>
<th>Brand</th>
<th>Color</th>
</tr>
</thead>
我该怎么做?
更新
我在创建一个新的帮助类时找到了解决方案: click me
【问题讨论】:
-
@PeterB with "Model.First()" 我可以访问属性值。但我实际上不想显示值,而是显示属性的显示名称。
标签: asp.net asp.net-mvc model-view-controller