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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -