I am trying to add a partial view to my MVC4 web application and I receive the following exception:
The model item passed into the dictionary is of type '...Meeting', but this dictionary requires a model item of type 'System.Collections.Generic.List`1[...UserProfile]'.
what I did so far:
- i added to my controller this function:
public PartialViewResult GetUsers() { var usersList = (from users in db.Users select users).ToList(); return PartialView(usersList); }
- I added the parital view:
@model List<UserProfile> @{ <select id="Meeting_SetToUser" name="Meeting.SetToUser"> @foreach (var item in Model) { <option value="@item.UserId">@item.FirstName @item.LastName</option> } </select> }
- i called the partialview from my view:
@Html.Partial("GetUsers")
can you please direct me to were I am doing anything wrong?
Thank you!
GetUsersaction? - Darin Dimitrov@Html.Partial("GetUsers")you just render the PartialView and pass the View's Model to it, notList<UserProfile>. - Zabavsky