Getting a selectd item back from a MVC dropdown list view ?
Posted on 2013-01-23
I have a drop down list that I populate in my MVC controller with the following code.
var allCustomers = _customerService.GetCustomersByCustomerRoleId(3, false);
var customerList = new List<SelectListItem>();
foreach (var cr in allCustomers)
var item = new SelectListItem()
Text = cr.Email,
Value = cr.Id.ToString()
ViewData["CustomerID"] = customerList;
In the cshtml file the drop down list is populated with the following code.
Everything is working just fine.
My question is how do you return the selected value from the drop down list to the controller?