I Have 2 views. ProductForm.aspx and Category.ascx. CategoryForm is a Partial View. I Call the Category.ascx from the ProductForm with EditorFor(model => model.Category) . In this partial view, there is a DropdownlistFor with all the category. The problem is the Selected Value for a specific Product Category. The selected value dosen't work.
Why ?
Here is what I have in my ProductForm
<div class="editor">
<div class="editor-label">
<%: Html.LabelFor(model => model.ProductInfo.ProductName) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.ProductInfo.ProductName)%>
<%: Html.ValidationMessageFor(model => model.ProductInfo.ProductName)%>
</div>
</div>
<%: Html.EditorFor(model => model.ProductInfo.Category, new { CategoryList = Model.CategoryList })%>
In Category.ascx
<div class="editor-field">
<%:Html.DropDownListFor(model => model.CategoryID, (IEnumerable<SelectListItem>)ViewData["CategoryList"])%>
</div>