Html.ListBox
I am trying to iterate over items in a list using asp.net mvc
Html.ListBox("SupplierId",
new SelectList(Model.Suppliers, "Id", "Name", Model.SelectedSuppliers))
Below is a view
var viewData = new ViewData.SubstrateEditViewData(
new DataAccess.SubstrateRepository().GetItemById(id),
new DataAccess.SupplierRepository().GetItems(),
new DataAccess.SupplierSubstrateRepository().GetItems().Where(s => s.SubstrateId ==id).Select(s => s.Supplier));
for some reason its no items selected, even though I can see the Model.SelectedSupplier containing two provider objects.
thanks
+1
jeanre
a source
to share
3 answers
the documentation for the SelectList constructor refers to a single value. It's not like walking through a List or IEnumerable values will result in a list with multiple selected values.
0
a source to share