You are passing no second param to the partial view so it is using the same Model as the parent view. Your parent view's model is a List of movies so your partial view is given a List of movies, but your partial view's @model directive says it wants a single
movie. This code;
What are you expecting the partialmovie to show? The first movie you have in the model? The last one? A random one? Every one? If you want to list every movie with a partial view showing each then you probably want code like this
<div id="divPartialView">
@foreach(Movie m in Model)
{
@Html.Partial("PartialMovie", m)
}
</div>
The above passes a single movie into the partial view, one at a time
I'm afraid I no longer use this forum due to the new point allocation system.
All-Star
37441 Points
9076 Posts
Re: Error When Running Application in the Partial View
Apr 08, 2014 08:37 AM|AidyF|LINK
You are passing no second param to the partial view so it is using the same Model as the parent view. Your parent view's model is a List of movies so your partial view is given a List of movies, but your partial view's @model directive says it wants a single movie. This code;
What are you expecting the partialmovie to show? The first movie you have in the model? The last one? A random one? Every one? If you want to list every movie with a partial view showing each then you probably want code like this
The above passes a single movie into the partial view, one at a time