Hi,
I have a form with a list of objects (DayList). in each list item I like to use a select tag helper to alter the selected shift
This is my model:
public string ScheduleName { get; set; } public bool NameChanged { get; set; } public string Message { get; set; } public class ScheduleDay { public int DayNr { get; set; } public Shift Shift { get; set; } public bool Changed { get; set; } } public List<ScheduleDay> DayList { get; set; } public List<SelectListItem> ShiftList { get; set; } public void OnGet(int ScheduleId) { //Get all data from Database. }
In My cshtml file I want to do this:
<table id="scheduleTable"><tr><th width="100px">
Day</th><th width="100px">
Date</th><th widht="100px">
Schift</th></tr>
@foreach (var item in Model.DayList)
{<tr><th width="100px">
@Html.DisplayFor(modelItem => item.DayNr)</th><th width="100px">
Date</th><th width="100px"><select asp-for="item.Shift.ShiftId" asp-items="@Model.ShiftList"></select></th></tr>
}</table>
But I get the error message "Model does not contain a definition for "item" ...
How should I do this ?