locked
Deselect everything from the ListBox in Edit View RRS feed

  • Question

  • User657329123 posted

    Hi there,

    I have a multi-select list box like this.

    @Html.ListBoxFor(model => model.Subjects, (MultiSelectList)ViewBag.Sub, new { @multiple = "multiple", @class = "form-control" })

    Initially nothing is selected from the list;  then user selects something from the list and it is saved in the database. When user tries to Edit there is no option to deselect everything from the list. How do I let user deselect everything from the list?

    Joe

    Wednesday, January 23, 2019 12:27 PM

All replies

  • User475983607 posted

    You must set selected item(s) in the ViewBag.Sub.  Where is the code that selects items?

    https://stackoverflow.com/questions/21826280/selectedvalues-not-working-in-multiselectlist-mvc

    When user tries to Edit there is no option to deselect everything from the list. How do I let user deselect everything from the list?

    Just click the item to remove the selection.  Can you provide code that reproduces this issue?

    Wednesday, January 23, 2019 12:35 PM
  • User657329123 posted

    Just found it since it is multi select list box, user can deselect items from list box by clicking Ctrl key.

    Wednesday, January 23, 2019 1:33 PM
  • User1520731567 posted

    Hi joegreen2005,

    Just found it since it is multi select list box, user can deselect items from list box by clicking Ctrl key.

    I'm glad that you have solved the issue by yourself.

    For user-friendliness,I suggest you could add some tips to let users know how to deselect.

    And  you could also mark the right reply as answer.

    This will help other people who faces the same issue.

    Thank you very much.

    Best Regards.

    Yuki Tao

    Thursday, January 24, 2019 8:16 AM