Calling partial view from _Layout.cshtml

后端 未结 1 744
一个人的身影
一个人的身影 2021-01-24 08:53

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条回答
  •  忘掉有多难
    2021-01-24 09:34

    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)
        {
            
        }
    

    Note: Change TypeofYourViewModel to whatever ViewModel you are passing into the partial view

    0 讨论(0)
提交回复
热议问题