【发布时间】:2016-08-05 16:57:13
【问题描述】:
问题是我有一个表单,在这个表单内我有一个下拉列表,其中包含来自数据库的学生的姓名,我想在每次从这个下拉列表中选择任何值时提交表单。当我尝试这段代码时:
@Html.DropDownList("StudentId", "--Select Students--", new { onchange = "this.form.submit();" })
出现一个错误:
StudentId 是一个 ViewBag,其中包含来自的学生列表 控制器动作中的数据库
【问题讨论】:
-
@Html.DropDownList("StudentId", null, "--Select Students--", new { onchange = "this.form.submit();" })假设StudentId是IEnumerable<SelectListItem> -
是的,谢谢
标签: c# asp.net asp.net-mvc asp.net-mvc-4 html-select