当我点击提交按钮时,请帮助我获取控制器中下拉列表的选定值。
My view is like
@using (Html.BeginForm())
{
@foreach (var department in @Model)
{
items.Add(new SelectListItem
{
Text = @department.DeptName,
Value = @department.DeptId.ToString()
});
}
@Html.DropDownList("deptID", items, "--Select One--", new { @style = width:160px" }) *
<input type="submit" name="Filter" value="filter" />
}
Please share if you are having any website link which explains about the dropdown list and its events in mvc3 Razor.
由于 圣
答案 0 :(得分:3)
如果你有一个同名的参数
,MVC会为你处理绑定public ActionResult MyAction(string deptID)
{
// whatever
}