-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Description
Description
The following code does not do what is described:
DepartmentNameSL = new SelectList(departmentsQuery.AsNoTracking(), nameof(Department.DepartmentID), nameof(Department.Name), selectedDepartment);
The 4th argument "selectedDepartment" does not do anything in this context because in the select tag helper, the asp-for parameter is specified as "Course.DepartmentID".
<label asp-for="Course.Department" class="control-label"></label> <select asp-for="Course.DepartmentID" class="form-control" asp-items="@Model.DepartmentNameSL"> <option value="">-- Select Department --</option> </select> <span asp-validation-for="Course.DepartmentID" class="text-danger"
The selected option is driven by Model.Course.DepartmentID.
The same mistake is perpetuated throughout the tutorial.
Page URL
https://learn.microsoft.com/en-us/aspnet/core/data/ef-rp/update-related-data?view=aspnetcore-9.0
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/data/ef-rp/update-related-data.md
Document ID
9bc46ffa-60db-bdee-0984-fab183c8f503
Platform Id
2a5fd416-38e1-f258-ef22-118e7bf1ac71
Article author
Metadata
- ID: 140ce637-4d58-995f-c69e-b1de51f1dbb5
- PlatformId: 2a5fd416-38e1-f258-ef22-118e7bf1ac71
- Service: aspnet-core
- Sub-service: data-access