Archived page · captured 2011-02-16

Html.DropDownList Not Working?

Archived 2009 ASP.NET MVC post explaining how to make Html.DropDownList work by supplying a SelectList from the controller.

Article information

This post was published on The C#rypt by mhenrixon on 31 January 2009 at 14:17 and is tagged MVC.

Problem

The author explains that Html.DropDownList was not working and that clear information about the problem was difficult to find.

Solution

The view should use the helper with one parameter: <%= Html.DropDownList("CustomerID") %>

The example controller action loads an invoice, retrieves customers, creates the SelectList from that data, and passes it to the view through ViewData.