I have created a partial view which returns a list of items where the ItemsId
matches the one passed to it.
//
// GET: /ItemOptions/Item/5
public ActionResult Item(int id = 0)
{
var itemoptions = db.ItemOptions.Where(o => o.ItemsId == id);
return PartialView(itemoptions.ToList());
}
I am trying to display this on the details page of the parent item using the following code:
@Html.Partial("../ItemOptions/Item", Model.ItemsId)
If I visit {URL}/ItemOptions/Item/1 it returns the table I am expecting to see. But if I navigate to the parent item where I am trying to include the partial view I get the following error:
The model item passed into the dictionary is of type 'System.Int32', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[shopServer.Models.ItemOptions]'.
I have read other posts but can't work out where I am going wrong. I also read that I may need to use @Html.Action instead of Partial views, but I am unsure which is appropriate in which situation.