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
) and has this surrounding it:
@foreach (var item in Model) {
}
The code is using this overload of DisplayFor:
public static MvcHtmlString DisplayFor(
this HtmlHelper html,
Expression> 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.