【发布时间】:2014-10-23 16:19:23
【问题描述】:
我的视图中有一个下拉菜单、几个其他控件和一个用于保存数据的输入按钮。 保存时我有 ActionReult Save () 这需要我在下拉列表中选择的值。 如何在我的控制器 Actionresult Save() 上获取下拉列表的选定值
View:
------
Collapse | Copy Code
var docTypes = Model.DocumentTypes.Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString()}).AsEnumerable();
@Html.DropDownList("SelectedDocumentType", docTypes, "--select--", new { @class = "ddSelect" })
Model:
-----
Collapse | Copy Code
public IEnumerable DocumentTypes { get; set; }
Controller:
-----------
Collapse | Copy Code
[HttpParamAction]
[HttpPost]
[ValidateInput(false)]
public ActionResult Save()
{
int DocumentType = // I have to assign the selected value of the dropdownlist here
}
【问题讨论】: