I just saw modelItem
in some scaffolded MVC code and I'd thought I'd just add to bunglesticks answer.
The piece of code in the question probably comes from a standard MVC scaffolded index view (where the model is an IEnumberable<TModel>
) and has this surrounding it:
@foreach (var item in Model) {
}
The code is using this overload of DisplayFor:
public static MvcHtmlString DisplayFor<TModel, TValue>(
this HtmlHelper<TModel> html,
Expression<Func<TModel, TValue>> expression
)
Therefore the modelItem (as bunglestink said) is doing nothing (it's not used in the result). The item.LastName
returns the actual LastName for that item in the IEnumerable and DisplayFor
will generate the correct html for the datatype.