0

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.

mj1313
  • 7,930
  • 2
  • 12
  • 32

1 Answers1

0

You can try to change you code like below:

  <select size="7" style=" width: 275px; color:#967a42;" class="table-dark" name="OptionsToAdd"  asp-items="@(new SelectList(@ViewBag.OptionsDD, "Value", "Text"))" multiple> 
    </select>
Yinqiu
  • 6,609
  • 1
  • 6
  • 14