ASP.NET MVC dropdownlist not selecting value on render

前端 未结 8 772
感动是毒
感动是毒 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:40

    Also Html.DropDownListFor uses values from POST request.

    Therefore if you have the same parameter in POST data MVC will use it even if you have different value in model.

    Check if you have the same name in request and change it.

提交回复
热议问题