I have the following partial view called _Categories residing in ~/Views/Category/_Categories:
@model IEnumerable<MyBlogSite.Models.BlogPostCategory>
<ul>
@foreach (var item in Model)
{
<li>@Html.DisplayFor(modelItem => item.Name)</li>
}
</ul>
I have the following Index view at ~/Views/Blog/Index.cshtml:
@model IEnumerable<MyBlogSite.Models.BlogPost>
@{
ViewBag.Title = "Index";
}
@Html.RenderPartial("~/Views/Category/_Categories.cshtml", ---- );
<p>
@Html.ActionLink("New Blog Post", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Title)
</th>
...
In the space of the dashes (----) above is where I have been trying to figure out how to pass the model in. I cannot use Model.BlogPostCategory because it only accepts Model.BlogPost. I have also tried "model" with a lower-case "m" as per a couple of posts that I saw here.
I create viewmodel for my partialview, then pass data its. For example: my viewmodel
partialview
and View with calling partialview