formcollection only holds the selected html.listbox items values? MVC

前端 未结 3 591
刺人心
刺人心 2020-12-29 08:38

My scenario is this: I have two listbox\'s, one that contains all my database items, and an empty one. The user adds the items needed from the full listbox to the empty list

3条回答
  •  醉话见心
    2020-12-29 09:34

    Because it's just selectbox. You cannot post all values in selectbox. You have to use javascript to catch added items and store them in hidden input.

    Un-tested code, but i think it help you.

    
    <%= Html.Hidden("hdSelectedItems") %>
    <%= Html.ListBox("AllItems", Model.Items)%>
    <%= Html.ListBox("lbSelectedItems") %>
    Add
    

提交回复
热议问题