What would I give to asp-for property of a label tag helper in order to display items from a collection. The code below generates a compilation error.
@foreach (var item in Model)
{
<label asp-for="item.BookingCode"></label>
}
What would I give to asp-for property of a label tag helper in order to display items from a collection. The code below generates a compilation error.
@foreach (var item in Model)
{
<label asp-for="item.BookingCode"></label>
}
The @ character escapes the default model lambda code. Therefore you can type:
@foreach (var item in Model)
{
<label asp-for="@item.BookingCode"></label>
}
<label> will not be that important here. But if you wan to use it, as @JoelCunningham stated, use <label asp-for="@item.BookingCode">@item.BookingCode</label> asp-for value will display the heading as a property name and @item.BookingCode inside <label ...>...</label> will display the value of @item.BookingCode.