我想从下拉列表中单击一下显示数据。我该怎么办?我是ASP.NET MVC的新手。
以下是“索引我的视图”:
<div class="form-group">
@Html.Label("Process", htmlAttributes: new { @class = "control-label col-md-1" })
<div class="col-md-4">
@Html.DropDownList("ProcessID", null,"Please Select", htmlAttributes: new { @class = "form-control", onchange = "CallChangefunc()" })
@*@Html.ValidationMessageFor(model => model, "", new { @class = "text-danger " })*@
</div>
</div>
我在控制器上的方法:
public ActionResult Index(int? ProcessID = null)
{
ViewBag.ProcessID= new SelectList(db.Processes, "ProcessID", "ProcessName");
var agendaList = db.AgendaUploads.Where(l => l.ProcessID == ProcessID).ToList();
return View(agendaList);
}
我有这个脚本:
<script>
function CallChangefunc(val)
{
window.location.href="/AgendaUploads/Index?q="+val;
}
</script>
如何在下拉菜单中更改时获取数据?预先感谢。