asp.net mvc 2 - How to get the selected value of some dropdownlist, called several times on a loop? -
On my application, I need to display some dropdown list, which is linked to a display line. However, I do not know that, the selected value of my debitist is never displayed ... I have selected the value of a single decoder No problem was found, but when on a loop .. I do not know what to do ... Any ideas? If you have more than one dropdown list displayed You may need to customize your visual model, so let's take an example: is a controller action that populates this visual model The public performance index () {var model = new MyViewModel {items = new [] {// TODO: new itemsViewModel {label = "label 1", labeled value = new [] New SelectListItem {value = "1", text = "item1"}, New SelectListItem {value = "2 fetch" item "=" new "] {new SelectListItem {value =" A ", Text =" foo1 "}, New SelectListItem {Value =" B ", Text =" bar "}}},}} Return Scene (Model); } and then there is a related strongly typed view: and in the same editor template ( & lt; Table & gt; & Lt;% foreach (Miscellaneous items in the model) {%> & Lt; TD & gt; & Lt;% = Html.Encode (item.COMPETENCE_LIBELLE)% & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt;% = Html.DropDownListFor (item.FK_NIVEAU_ID, ViewLata) "[FK_Niveau"]%>
public square item viewmodel {public string label {get; set;} Public string selected I {get} set;} public IEnumerable & LT; SelectListItem & gt; value {get; set;}} public class MyViewModel {public IEnumerable & LT; ItemsViewModel & gt; items {get; set;}}
& lt; Table & gt; & Lt; Thead & gt; & Lt; TR & gt; & Lt; Th & gt; Label & lt; / Th & gt; & Lt; Th & gt; Value & lt; / Th & gt; & Lt; / TR & gt; & Lt; / Thead & gt; & Lt; Tbody & gt; & Lt;% = Html.EditorFor (x = & gt; x.Items) & lt; / Tbody & gt; & Lt; / Table & gt;
~ / visual / share / editorTemplates / ItemsViewModel.ascx ):
Comments
Post a Comment