tags:

views:

634

answers:

2

Hi,

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.CalculationClassCollection, new SelectList(Model.CalculationClassCollection, "ID", "Name", 3 ), new { id = "ddCalculationClass" })%>

Anybody can help me?

A: 

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.

uriDium
A: 

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

Jay Shanker
Thank you! It works!