Reputation: 274
Basically I have a view model
public class VM_MachineCheckSheet
{
public List<checksheet> checksheet;
public List<MvcApplication2.Models.Machine.machine> machine;
}
My main View
@model MvcApplication2.Models.CheckSheet.VM_MachineCheckSheet
@{
ViewBag.Title = "MachineCheckSheet";
}
@Html.RenderPartial("_MachineCheckBoxListPartial", Model.machine);
and my Partial View
@model IEnumerable<MvcApplication2.Models.Machine.machine>
<div id = "machine_filter" class = "machine_filter")
<table>
<tr>
I populate the viewmodel in my controller then pass it to the main view and then pass only machine to the partial view which is strongly typed with IEnumerable<machine>
this is the error i get
Compiler Error Message: CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult) 'has some invalid arguments Line 7: @Html.RenderPartial("_MachineCheckBoxListPartial", Model.machine);
I don't know why there is a type mismatch between List of machine in the partial view and the one being passed in from the view model. They are the same thing. Any ideas?
Upvotes: 2
Views: 418
Reputation: 10694
You need to change
@Html.RenderPartial("_MachineCheckBoxListPartial", Model.machine);
To
@{ Html.RenderPartial("_MachineCheckBoxListPartial", Model.machine); }
Upvotes: 2