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 -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -