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.
精彩评论