asp.net mvc - Set values to the items in DropDownListFor in a view -
i have this:
<div class="editor-field"> <%: html.dropdownlistfor(m => m.language, new selectlist(new[] { "string1", "string2", "string3", "string4" }, "string1"))%> </div> i want strings have values. example, string1, have value=1, string2: value=2, etc. how this?
just use
new list<selectlistitem>(){ new selectlistitem{text="item1", value = "valuer1", ... } or use selectlist pass dictionary or list<> of custom objects.
Comments
Post a Comment