c# - option select in razor can't work for me -


this code doesn't work me:

<div class="col-md-4">   @html.dropdownlistfor(m => m.etattik,      new selectlist(new list<object>     {        new { value = 0 , text="text1"  },       new { value = 1 , text = "text2" },       new { value = 2 , text = "text3"}     })   )   @html.validationmessagefor(m => m.etattik) </div> 

it shows me { value = 0 , text=text1 }

you did not specify datavaluefield , datatextfield selectlist:

@html.dropdownlistfor(                         m => m.etattik,                          new selectlist(                                   new list<object>{                                     new { value = 0 , text="text1"  },                                 new { value = 1 , text = "text2" },                                   new { value = 2 , text = "text3"}                                 }                     , "value", "text")                         ) 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -