Displaying a List

We still have an issue in Artist division. How to display items from collection? Yes, use looping.

In razor, we could do something like this.

<h5>Artist:</h5>
<div>
    <ul>
        @foreach (var artist in artists)
        {
            <li>@artist</li>
        }
    </ul>
</div>

Yeah, it looks better now.

Moreover, we could do simple conditional statement shown below.

@if (artists.Length > 0)
{
    <h5>Artist:</h5>
    <div>
        <ul>
            @foreach (var artist in artists)
            {
                <li>@artist</li>
            }
        </ul>
    </div>
}

results matching ""

    No results matching ""