How do I submit the ListBox selections to the ModelBinder?
<%=Html.Hidden("response.Index",index)%>
<%=Html.ListBox("response[index].ChoiceID",
new MultiSelectList(gc.choice,"ChoiceID","ChoiceText") )%>
'gc.choice' is a List
I can get the fisrt selected value to the model, but not the second selection presumably because I cannot change the index.
I have solved this in a slightly different way...
So the model has an IEnumberable that will be populated with the user-selections. The view displays the ListBox with the MultiSelectList and the controller passes in the SelectedStores from the model when it constructs the MultiSelectList.
I built a presentation model
SamplePresentationModel
class that has a MultiSelect memberuserList
. Then supposeIEnumerable<User> allUser
is the list of options. I useto pass the MultiSelection to the view.
Then in the view I can construct the listbox
In the POST action I can capture the selections:
Don't know if this helps!