我看到this,但我有不同的问:我有这样一个观点:级联两个@ Html.DropDownListFor的更新中MVC4与模型结合
@model myPrj.Models.RollCallModel
...
<table>
<tr> //Master DDL
<td>
@Html.LabelFor(model => model.CourseID)
@Html.DropDownListFor(model => model.CourseID,
new SelectList(new myPrj.Models.myDbContext().Courses
.Where(c => c.StatusID == 0), "ID", "ID"),
"choose...", new { id = "ddlCourse"})
@Html.ValidationMessageFor(model => model.CourseID)
</td>
</tr>
<tr> //Detail DDL
<td>
@Html.LabelFor(model => model.PersonnelID)
@Html.DropDownListFor(model => model.PersonnelID,
null, "choose another...", new { id = "ddlPersonnel"})
@Html.ValidationMessageFor(model => model.PersonnelID)
</td>
</tr>
</table>
...
我有足够的了解与jquery级联更新。我的问题是,是否可以对这些DDL执行级联更新,而无需为Detail DDL编写<option>something</option>
迭代?如果不是,最好的选择是什么?
注:其实我试图渲染,因为模型的结合公约的HTML辅助细节DDL。如果我别无选择,只能将其渲染<select id=""></select>
,那么如何将此select
元素绑定到模型?
感谢名单
更新:看来,有没有办法......(仍在等待确实搜索...)