I am trying to pass a list of several items to a view via ViewData to create a drop down list. This should not be too complicated, but I'm new to MVC, so I probably don't see anything obvious.
The controller assigns a ViewData list:
ViewData["ImageLocatons"] = new SelectList(gvr.ImageLocations);
and the view tries to display it in the drop-down list:
<%= Html.DropDownList("Location", ViewData["ImageLocations"] as SelectList) %>
However, when I run it, I get this error: There is no ViewData element of type "IEnumerable" that has a location key.
Any ideas why this is not working? Also, shouldn't he look for the key "ImageLocations", not the location?
source
share