I have a Razor View with a dropdown list:
<select size="7" style=" width: 275px; color:#967a42;" class="table-dark" asp-for="OptionsToAdd" asp-items="@(new SelectList(@ViewBag.OptionsDD, "Value", "Text"))" multiple></select>
When I submit the page, the controller resets the list and selected items, yet when the view is displayed, the same items are still selected from before the POST. How can I clear this?
This only happens in the view. The model that is passed in has all items in the Viewbag.OptionsDD with selected=false.
You can try to change you code like below: