'Dynamic Menus Binding in mud blazor Navigation Menu component

I'm trying to use a foreach loop in a MudBlazor Nav menu component.

<MudNavMenu>
        @{
            if (dtX != null && dtX.Rows.Count > 0)
            {               
                for (int i = 0; i < @dt.Rows.Count; i++)
                {
                    Program_ID = Convert.ToInt32(@dt.Rows[i]["Program_ID"]);
                    Program_Icon2 = dt.Rows[i]["Program_Icon"].ToString();
                    <MudNavGroup  Title="@Program_Name">
                        @foreach (DataRow dr in dt2.Rows)
                        {
                            Program_ID_Level2 = Convert.ToInt32(dr["Program_ID"]);
                            Program_Name_Level2 = dr["Program_Name"].ToString();
                        }
                    </MudNavGroup>
                }
            }
        }
</MudNavMenu>

Running this doesn't throw any exceptions but it seems that MudBlazor components are unable to use looped elements. How else can I loop through them?



Solution 1:[1]

You are missing MudNavLink that should be in MudNavGroup

Added minimal working example as asked:

<MudNavMenu>
        @if (_menuList != null && _menuList.Count > 0)
        {
            <MudNavGroup Title="Example">
                @foreach (var item in _menuList)
                {
                    <MudNavLink Href="@item">@item</MudNavLink>
                }
            </MudNavGroup>
        }
</MudNavMenu>


@code {
    private List<string> _menuList = new List<string>();

    protected override void OnInitialized()
    {
        for (int i = 0; i <=5; i++)
        {
            _menuList.Add($"Menu Item {i}");
        }
    }

}

Solution 2:[2]

This behavior is explained in the documentation.

enter image description here

to get the actual value you must use:

GET https://api.notion.com/v1/pages/<PAGE_ID>/properties/<PROPERTY_ID>

and the response will be somthing like this:

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Geraldo Ferraz