I have a main category and main category has its subcategory list in database. So its a relational database. For better understanding .edmx map picture is attached. Now my goal
1.Change @Html.Partial("_GuestNav") to @{Html.RenderAction("_GuestNav", "YourControlerName");}
2.Add @Model TypeofYourViewModel
on top of your partial view.
3.Change the looping as follows:
@foreach (var item in Model)
{
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">@item.MainCatName<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
@foreach (var subcat in item.subcat)
{
<li><a href="#">subcat.SubcatName</a></li>
}
</ul>
</li>
}
Note: Change TypeofYourViewModel to whatever ViewModel you are passing into the partial view