asp.net mvc 3 - MVC data annotations and templates -
in mvc scaffold code understand template being used , can define own templates. also, data annotations on object sent view being taken account.
but modelitem?
@foreach (var item in model) { <tr> <td> @html.displayfor(modelitem => item.referencenum) </td>
modelitem
unuses background variable.
displayfor
expects method receives single parameter. implementation of method is, de-facto, right side of lambda expression: item.[something]
. happens item.[something]
totally ignores modelitem
. replacing modelitem
item
would, of course, result in compilation error, because item
belongs model
, , it's not object created when calling anonymous method { item.[something] }
.
that's why modelitem
can practically name doesn't exist in symbols table (i.e. compiler doesn't have definition for).
Comments
Post a Comment