I have an Approval class, which has a list of ApprovalDocument objects.
The Approvals class has an ActiveApprovalDocument property.
My model has a list of Approvals.
I want too show a property of the active approval document:
<%= Html.DisplayFor(m => m.Approvals[i].ApprovalDocuments[m.Approvals[i].ActiveApprovalDocumentsId.Value].CertificationIssuedDate)%>
I realise I could just directly display Model.Approvals[i].... but how can I still use the DisplayFor (so I get the automatic formatting etc.)?
The error I get is:
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
Or just use a view model.