After trawling the threads I've almost got my DownDownListFor working, but I'm getting a strange validation fail. Please help.
I'm using a .NET 2.5 and an SQL DB back end, made available via the EntityFramework. Validation is setup via MetadataTypes.
The object I'm trying to create is called Deal, it has 3 look-up value fields, LocationId, CompanyId and CategoryId. Each look up field is controlled by a db table/framework entity. On the front end I want the user to select the look up values via a dropdown list.
Each dropdownlist is set up in the same way so I'll concentrate on Category.
Controller GET code:
var cat = db.Categories.ToList().OrderBy(c => c.CategoryName); ;
ViewData["Categories"] = cat;
<%= Html.DropDownListFor(c => c.Category.CategoryId, new SelectList((IEnumerable)ViewData["Categories"], "CategoryId", "CategoryName"), "-- Select Category --")%>
<%= Html.ValidationMessageFor(model => model.Category.CategoryId)%>
Controller POST code:
View Complete Post