开发者

ASP.NET MVC Html.DropDownListFor Select value

开发者 https://www.devze.com 2022-12-27 06:30 出处:网络
I have a little problem. I use the Html.DropDownListFor helper to render a dropdown list to the client.

I have a little problem. I use the Html.DropDownListFor helper to render a dropdown list to the client.

But I can't set the selected value in dropdown list.

<%= Html.DropDownListFor(model => Model.CalculationClassCol开发者_运维百科lection, 
new SelectList(Model.CalculationClassCollection, "ID", "Name",  3 ), 
new { id = "ddCalculationClass" })%>

Anybody can help me?


If the SelectList is not a member of my Model, I'd use <%= Html.DropDownList("listBoxID", new SelectList(Model.CalculationClassCollection, "ID", "Name", 3 ))%>


It is one of the overloaded methods. I think it is the method with a parameter something like default. Sorry I am not in front of dev PC right now so I can't tell you exactly which method it is.

0

精彩评论

暂无评论...
验证码 换一张
取 消