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
Post a Comment