title: Multiple Models in one view
body: <p>I am working on a site that has a Layout with multiple partial views on it. These Partial views have models with a database connected to them. I can display the partial views separately but not on the same layout. I used the code first approach so i have a entities model that has all of my models in it. The database was generated and connected. I have data in the tables and i am currently displaying these in the admin section for editing and deleting etc. I am not sure what i am doing wrong.
  Here is my layout partial call:</p>
  
  <pre><code>    &lt;li&gt;@Html.Partial("_SubCategory")&lt;/li&gt;
  </code></pre>
  
  <p>My controller is a list - currently in the auditScheduleController:</p>
  
  <pre><code>    public ActionResult _SubCategory()
      {
          return View(_db.SubCategories.ToList());
      }
  </code></pre>
  
  <p>In my partial view i have put a number of senarios and non seem to work. If i put
          <code>@model IEnumerable&lt;QQAudit.Models.Subcategory&gt;</code>
  I can display the page by itself and get a list of the Subcategories. It faults out if i open it up through the layout. Saying something about </p>
  
  <blockquote>
    <p>"The model item passed into the dictionary is of type 'System.Data.Entity.DynamicProxies.AuditSchedule_5218AAD34020C54DC3FF0CFD6169988BB5FED2C296ABF80AC3EFFF93441CE91B', but this dictionary requires a model item of type 'QQAForm.Models.SubCategory'.</p>
  </blockquote>
  
  <p>I have looked on different forums and found some things but everything i have tried that is out there seems to fail in some fashion. </p>
  
  <p>The funny thing is my background is Zend PHP and i can do what i am tring to accomplish there but cannot duplicate it in MVC3 C#.</p>
  
  <p>August 01 2012</p>
  
  <p>I am at the point were i want to add the ID of the page to the link I have already changed the global.asax to be:</p>
  
  <pre><code>            routes.MapRoute(
              "AuditSecion", // Route name
              "{controller}/{action}/{id}/{section}", // URL with parameters
              new { controller = "Home", action = "Index", id = UrlParameter.Optional, section = UrlParameter.Optional }, // Parameter defaults
              new[] { "QQAForm.Controllers" }
          );
  </code></pre>
  
  <p>I want the link to  populate the ID that the page is on. So the partial looks like this:</p>
  
  <pre><code>@{ Layout = null; }
  
  @model IEnumerable&lt;QQAForm.Models.SubCategory&gt;
  
  @foreach (var item in Model)
  {
  
  @Html.ActionLink(item.SubcategoryName, "audit", new { id = item.SubCategoryID }, null)
  
  }  
  </code></pre>
  
  <p>The subcategoryID should be the section and the ID should be the ID of the page which looks like this.</p>
  
  <pre><code>http://localhost:52490/AuditSchedule/Audit/1192
  </code></pre>
  
  <p>in theory the link of the submenu should be </p>
  
  <pre><code>http://localhost:52490/AuditShedule/Audit/1192/1
  </code></pre>
  
  <p>thanks for the help!</p>