ASP.NET MVC dropdownlist not selecting value on render

前端 未结 8 744
感动是毒
感动是毒 2020-12-29 12:56

I have this annoying problem where my DropDownlist doesn\'t select the current value by default.

Controller:

var YearsCycling = new SelectList(new Li         


        
8条回答
  •  再見小時候
    2020-12-29 13:31

    I have some problems when using a ViewBag with the same name as the html-element.

    So, doesn't use a DropDownList for EventId, when the SelectList is stored in a ViewBag.EventId.

    Change ViewBag.EventId to ViewBag.EventData, and it's fixed.

提交回复
热议问题