user295541
user295541

Reputation: 1015

ASP.NET MVC Html.DropDownListFor Select value

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?

Upvotes: 2

Views: 5893

Answers (2)

Jay Shanker
Jay Shanker

Reputation: 91

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

Upvotes: 3

uriDium
uriDium

Reputation: 13420

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.

Upvotes: 0

Related Questions