I have the following view ...
@model IEnumerable<Contact>
@{ ViewBag.Title = "Contact Manager"; }
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.FirstName)
</th>
<th>
@Html.DisplayNameFor(model => model.MiddleName)
</th>
<th>
@Html.DisplayNameFor(model => model.LastName)
</th>
<th>
@Html.DisplayNameFor(model => model.HomePhone)
</th>
<th>
@Html.DisplayNameFor(model => model.WorkPhone)
</th>
<th>
@Html.DisplayNameFor(model => model.MobilePhone)
</th>
<th>
@Html.DisplayNameFor(model => model.EMail)
</th>
<th></th>
</tr>
@*This first row is the search form*@
<tr>
<th>
@Html.EditorFor(model => model.FirstName)
</th>
<th>
@Html.EditorFor(model => model.MiddleName)
</th>
<th>
@Html.EditorFor(model => model.LastName)
</th>
<th>
@Html.EditorFor(model => model.HomePhone)
</th>
<th>
@Html.EditorFor(model => model.WorkPhone)
</th>
<th>
@Html.EditorFor(model => model.MobilePhone)
</th>
<th>
@Html.EditorFor(model => model.EMail)
</th>
<th></th>
</tr>
</table>
The problem is that "model" parameter in the predicate argument to the "EditorFor()" calls, refers to the IEnumerable and not the individual Contact item the way that seems to in the "DisplayNameFor()" method. Therefore, I am receiving Compilation Errors because the property name (for example: "FirstName") is not a property of the IEnumerable.
Intellisense actually returns me various IEnumerable methods (Such as "Select()") for the "method" parameter used in the predicate argument to the function. Oddly enough, even though the "DisplayNameFor()" method calls appear to work, intellisense does not show properties of the Contact.
What's the difference here?
Honestly, it makes sense that the since the model is IEnumerable this syntax would not work. However I am confused as to why it DOES work for the "DisplayNameFor()" method which is inserted by the wizard when you generate a strongly typed view as a list. Then in this case, why would it work for one (DisplayNameFor()) ... but not the other (EditorFor()).
Thank you, G