2

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&ltMvcApplication2.Models.Machine.machine&gt

<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&ltmachine&gt

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?

The_Outsider
  • 1,875
  • 2
  • 24
  • 42
Raza Jamil
  • 264
  • 1
  • 3
  • 12

1 Answers1

2

You need to change

@Html.RenderPartial("_MachineCheckBoxListPartial", Model.machine);

To

@{ Html.RenderPartial("_MachineCheckBoxListPartial", Model.machine); }

FOR MORE

Community
  • 1
  • 1
Nitin Varpe
  • 10,450
  • 6
  • 36
  • 60