MVC Dropdown list value not being set

前端 未结 2 602
一生所求
一生所求 2021-01-19 16:54

I\'m sure I am missing something obvious, but this is driving me nuts! If I specify html options, the value of my dropdownlist doesn\'t set.

In my controller, I ret

2条回答
  •  天命终不由人
    2021-01-19 17:41

    the second parameter of the DropDown Helper takes an object of type IEnumerable(Of SelectListItem) but you passed an object of type IEnumerable(Of SelectList) so this how the code should be written:

         <%=Html.DropDownList("Coordinator",((SelectList)ViewData["Coordinator"]).AsEnumerable(),
     new {style="width:175px"}) %>
    

提交回复
热议问题