ASP.net MVC DropDownList Pre-Selected item ignored

后端 未结 3 1017
说谎
说谎 2021-02-08 17:44

I am facing a simular problem as outlined in the question \"Html.DropDownList in ASP.NET MVC RC (refresh) not pre-selecting item\"

I\'m using ASP.net MVC 1.0 and need to

3条回答
  •  渐次进展
    2021-02-08 18:12

    Unfortunately i'm not at work so i can't get the actual code. However, I accomplished this by writing the javascript event as an html attribute in the Controller, then passed it along in the ViewData.

    When you write the code:

    <%=Html.DropDownList("SelectList", (SelectList)ViewData["SelectList"], [htmlAttribute])
    

    Basically in the Controller you would write the htmlattribute and assign it in the dropdownlist method.

提交回复
热议问题