如何在MVC中的Controller中获取DropDownList SelectedValue
我有下拉列表,我已从数据库中填写。现在我需要在Controller中获取所选值进行一些操作。但没有得到这个想法。我试过的代码。
public class MobileViewModel { public List<tbInsertMobile> MobileList; public SelectList Vendor { get; set; }}
public ActionResult ShowAllMobileDetails() { MobileViewModel MV = new MobileViewModel(); MV.MobileList = db.Usp_InsertUpdateDelete(null, "", "", null, "", 4, MergeOption.AppendOnly).ToList(); MV.Vendor = new SelectList(db.Usp_VendorList(), "VendorId", "VendorName"); return View(MV); } [HttpPost] public ActionResult ShowAllMobileDetails(MobileViewModel MV) { string strDDLValue = ""; // Here i need the dropdownlist value return View(MV); }
<table> <tr> <td>Mobile Manufacured</td> <td>@Html.DropDownList("ddlVendor", Model.Vendor, "Select Manufacurer") </td> </tr> <tr> <td> </td> <td> <input id="Submit1" type="submit" value="search" /> </td> </tr> </table>