There is no ViewData item of type ‘IEnumerable<SelectListItem>’ that has the key ‘myProperty’.
While figuring out the ASP.Net MVC 2.0 Preview 2 Expression HtmlHelpers (that’s a mouthful), I ran into this error a couple times. It didn’t make any sense to me because there shouldn’t be ViewData item with the key “MyProperty” with that type.
It turns out I was doing this:
<%= Html.DropDownListFor(x=>x.MyProperty, Model.AllMyPropertyListItems) %>
It throws this exception when AllMyPropertyListItems is null.
Comments(1)
What on earth are you trying to accomplish with the design of this site? Terribly unpleasant background and color scheme…free advice from one designer to another. One of those “Get me out of here, hit the back button as quickly as possible” moments.