我有一个 Approval 类,它有一个 ApprovalDocument 对象列表。
Approvals 类有一个 ActiveApprovalDocument 属性。
我的模型有一个Approval列表。
我也想显示事件批准文件的属性:
<%= Html.DisplayFor(m => m.Approvals[i].ApprovalDocuments[m.Approvals[i].ActiveApprovalDocumentsId.Value].CertificationIssuedDate)%>
我意识到我可以直接显示 Model.Approvals[i].. 但我怎么还能使用 DisplayFor(所以我得到自动格式化等)?
我得到的错误是:
System.InvalidOperationException: The expression compiler was unable to evaluate the indexer expression 'm.Approvals.get_Item(value(ASP.areas_approvals_views_approvals_index_aspx+<>c__DisplayClass0).i).ActiveApprovalDocumentsId.Value' because it references the model parameter 'm' which is unavailable. ---> System.InvalidOperationException: Lambda Parameter not in scope
请您参考如下方法:
<% var j = Model.Approvals[i].ActiveApprovalDocumentsId.Value; %>
<%= Html.DisplayFor(m => m.Approvals[i].ApprovalDocuments[j].CertificationIssuedDate) %>
或者只使用 View 模型。
