Fix incorrect SelectList selected item documentation and misleading comments #36032
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The ASP.NET Core Entity Framework Razor Pages tutorial incorrectly documented how SelectList selection works when using the Select Tag Helper with
asp-for
. The documentation and code comments suggested that theselectedDepartment
parameter in the SelectList constructor controls which option is selected, but this is not true.The Issue
When using the Select Tag Helper with
asp-for
, the selected option is determined by the model property value, not by the SelectList'sselectedDepartment
parameter:Changes Made
Documentation Updates:
selectedDepartment
parameter has no effect when using Select Tag Helper withasp-for
PopulateDepartmentsDropDownList
behavior across all moniker rangesCode Comment Fixes:
The fix ensures developers understand that when using
asp-for="Course.DepartmentID"
, the selected option is automatically determined by the value ofCourse.DepartmentID
, making theselectedDepartment
parameter redundant in this context.Fixes #35375.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Internal previews