Instead of this:
@foreach (var Item in Model.ItemsShipped) { <td width="70px" align="center"> @html.LabelFor(item.OnHandQty) <-- Cannot infer type from usage </td> }
Do it:
@Html.DisplayFor(model => model.ItemsShipped)
Then create a custom display template (placed in Views/Shared/DisplayTemplates/GridModel.cshtml ):
@model Namespc.Models.GridModel <td width="70px" align="center"> @html.LabelFor(model => model.OnHandQty) </td>
I have a feeling that this does not work because you are not passing the expression to the LabelFor method.
The above is much better and more reliable than the explicit for loop.
source share