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

前端 未结 7 1154
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条回答
  • 2020-12-14 10:18

    Ok I may be missing something from this thread however in C# the following works:

    Html.DropDownList("ProfessionGuid", (SelectList)ViewData["Professions"])
    

    Where 'ProfessionGuid' is the value to be selected in the list.

    In VB.Net I believe it would be:

    Html.DropDownList("ProfessionGuid", ViewData["Professions"] AS SelectList)
    
    0 讨论(0)
提交回复
热议问题