我有一个视图模型:
public class ObjectiveVM
{
public DateTime DatePeriod { get; set; }
public IList<ObList> obList { get; set; }
public class ObList
{
public int ObjectiveId { get; set; }
public int AnalystId { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string AnalystName { get; set; }
public bool Include { get; set; }
}
}
视图模型填充在控制器中,并具有我需要的信息:
在我看来,如何访问表头的 DisplayName:
@model IEnumerable<Objectives.ViewModels.ObjectiveVM>
...
...
<th>
@Html.DisplayNameFor(model => model.ObList.Include)
</th>
在上面尝试时,我收到错误:
'ObList': cannot reference a type through an expression; try 'Objectives.ViewModels.ObjectiveVM.ObList' instead
我也试过:
@model Objectives.ViewModels.ObjectiveVM
...但再次收到错误:
'ObList': cannot reference a type through an expression; try 'Objectives.ViewModels.ObjectiveVM.ObList' instead