DataBinding a DropDownList in ASP.NET MVC 2

Posted by Daniel Coffman on Stack Overflow See other posts from Stack Overflow or by Daniel Coffman
Published on 2010-04-15T19:38:32Z Indexed on 2010/04/15 19:43 UTC
Read the original article Hit count: 374

Filed under:
|
|

I'm extremely frustrated trying to switch to MVC after a couple years of webforms development.

Here's my extremely simple problem that I can't manage to solve: I have a list of States in a table called StateProvince. I have a DropDownList. I want the DropDownList to display all of the States in the StateProvince table and post the selected state back on HTTP PUT.

This is what I'm doing: <%: Html.DropDownListFor(model => model.StateProvinceId, new SelectList(Model.StateProvinces, "StateProvinceId", "Name") )%>

I'm getting an Object reference not set to an instance of an object. Why? How can I make this work?

Keep it simple, I know nothing about MVC.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about ASP.NET