When adding the category section, each category comes with one. But which element of the category do I want to attract, how can I do it.
I give examples from each category database. Category A has b c url. Category B also has URL b c. I have a table called Menu
. If the category is true, I try to match it with the id in the Menu
table from my Category
table and display it.
Data model:
public static veri.Kategoriler[] deneme
{
get
{
using (burakEntities db = new burakEntities())
{
return db.Kategorilers
.Include(p => p.Menuler)
.OrderByDescending(p => p.kategorilertarih)
.Where(p => p.KategoriAktif == "true"
& p.Menuler.KategoriMi == "true"
& p.Menuler.MenuMi == "false"
& p.Menuler.Menulerid == p.Menulerid)
.ToArray();
}
}
}
_category.cshtml
view:
@foreach (var item in Model)
{
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
@item.Menuler.MenuAdi
</a>
<!-- Dropdown menu -->
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
<li>
<a class="dropdown-item" href="#">@item.kategoriAdi</a>
</li>
</ul>
</li>
}
Output:
2
Answers
problem solved
I think you need to place your foreach inside the following code block. You are looping on a higher level; around the UL, thus you get more dropdowns instead of more dropdown-items.