ASP.NET MVC Html.DropDownListFor Select Value

I have a little problem. I am using the Html.DropDownListFor helper to display the dropdown to the client.

But I cannot set the selected value in the dropdown.

<%= Html.DropDownListFor(model => Model.CalculationClassCollection, 
new SelectList(Model.CalculationClassCollection, "ID", "Name",  3 ), 
new { id = "ddCalculationClass" })%>

      

Can anyone help me?

+2


a source to share


2 answers


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



+3


a source


This is one of the overloaded methods. I think it is a method with a parameter similar to the default. Sorry that I'm not right in front of dev right now, so I can't say exactly which method.



0


a source







All Articles