ASP.NET MVC - Html.DropDownList - Value not set via ViewData.Model

前端 未结 7 1179
Happy的楠姐
Happy的楠姐 2020-12-14 09:24

Have just started playing with ASP.NET MVC and have stumbled over the following situation. It feels a lot like a bug but if its not, an explanation would be appreciated :)<

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-14 10:12

    My concern with this is that you may only use the list for one field. I have Entities with multiple user fields, so I use the following:

    < %= Html.DropDownList("fieldAAA", 
                           new SelectList( (IEnumerable) ViewData["Users"], "Value", "Text", fieldAAA))
    
    %> 
    

提交回复
热议问题