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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -