为什么模型活页夹在编辑模式下的下拉列表中不起作用?
在编辑视图中,我编写了这段代码并测试了两个不同的 ddl:
@Html.DropDownList("ProductParentCategoryId", null, htmlAttributes: new { @class = "form-control" })
@Html.DropDownListFor(model => model.ProductParentCategoryId, (SelectList)ViewBag.ParentId)
在我的控制器中
ViewBag.ProductParentCategoryId = new SelectList(_productCategoryService.GetAllProductCategory(), "ProductCategoryId", "ProductCategoryTitle");
ViewBag.ParentId = new SelectList(_productCategoryService.GetAllProductCategory(), "ProductCategoryId", "ProductCategoryTitle");
但是编辑模式下的所有文本框都填充了模型活页夹,但下拉列表没有发生。
- - - -更新 - - - -
我的意思是在编辑模式下,模型绑定器将数据库中的所有数据绑定到文本框和每个元素中......但在下拉列表中模型绑定器不会将数据库中的数据作为选定值绑定到下拉列表中