I think I know what you are trying to do.
First of all, it seems that the model parameter that you use in your lambda expression is a reserved word in the browser - this is what causes an error of your type.
secondly, in order to solve your enumerable problem, in order to get both the label and the value, you will have to use the index of the value in IEnumerable
eg:
@using ISApplication.Models @model IEnumerable<PersonInformation> @ { List<PersonalInformation> people = Model.ToList(); int i = 0; } @foreach (PersonInformation item in people) { @Html.LabelFor(m => people[i].Name) // Error here. @Html.DisplayFor(m => people[i].Name) // But this line is ok @* and so on... *@ i++; }
EDIT:
This method only has a for loop, as there is currently no need to list the collection
@using ISApplication.Models @model IEnumerable<PersonInformation> @ { List<PersonalInformation> people = Model.ToList(); } @for(int i = 0; i < people.Count; i++) { @Html.LabelFor(m => people[i].Name) // Error here. @Html.DisplayFor(m => people[i].Name) // But this line is ok @* and so on... *@ }
source share