How to pass value of selected dropdownlist from view to the

Oct 23 2014 12:27 PM
Hi,

have a dropdown in my view, couple of other controls and a input button to save the data.
On saving I have ActionReult Save ()
which needs the value I selected in the dropdownlist.
How can I get the selected value of the dropdownlist on my controller 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 }

Answers (1)