asp.net mvc 3 listbox -
i'm trying add multiple selectlist
, creation work fine modification selected values data base failed show them in page, controller code
ilist<entite> liste = articledao.getbyid(id).entites; icollection<string> selectedvalues = new list<string>(); foreach (entite e in liste) { selectedvalues.add(e.nomentite); } multiselectlist entites = new multiselectlist(entitesdao.getall(), "id", "nomentite", selectedvalues); viewbag.listeentites = entites;
and view code:
<%:html.listbox("listeentites", viewdata["listeentites"] multiselectlist, new { size = "4" })%>
you populating selectedvalues
values datatextfield of select list - need populating datavaluefield:
foreach (entite e in liste) { selectedvalues.add(e.id); }
Comments
Post a Comment