title: Using viewmodel to pass different views to partial views
body: <p>I have a view that renders 2 partial views.  One partial is a list of people.  The other partial is a modal edit form to edit a single person.   I have a viewmodel that contains a person model and a list of person model.  I pass the viewmodel to the view and specify the specific models for the partials.  I get an error saying the view requires the PersonModel instead of the PersonViewModel. However, the view needs the viewmodel or it wont work.</p>
  
  <p>The Viewmodel:</p>
  
  <pre><code>public class PersonViewModel
  {
      public Person Person { get; set; }
      public List&lt;Person&gt; PeopleList { get; set; }
  }
  </code></pre>
  
  <p>The view (Index):</p>
  
  <pre><code>@model App.Models.ViewModels.PersonViewModel
  &lt;h1&gt;Manage People&lt;/h1&gt;
  
  @Html.Partial("_personEditForm", Model.Person)
  @Html.Partial("_PersonGrid", Model.PersonList)
  </code></pre>
  
  <p>The person edit partial calls the Person model:</p>
  
  <pre><code>@model App.Models.Person
  </code></pre>
  
  <p>and the grid partial calls the same model as a list:</p>
  
  <pre><code>@model List&lt;App.Models.Person&gt;
  </code></pre>
  
  <p>This works fine if the page has only one partial, but this is the first time I have tried it with 2 and it fails. The Index view must have the ViewModel for the partials to work, so not sure why it wont take it.</p>