我有dropdownlst,我从数据库填充。现在我需要在Controller中获取所选值进行一些操作。但是空数据会得到。我试过的代码。
##View##
@using (Html.BeginForm()) {
@Html.DropDownList("SupplierId", ViewBag.PurSupName as SelectList, new {@class = "form-control",style = "width: 200px;",id="supId"})
}
## Controller ##
public ActionResult ItemPurchased()
{
POS_DBEntities2 db = new POS_DBEntities2();
var query = from i in db.TBL_Account
where i.Type == "supplier"
select i;
ViewBag.PurSupName = new SelectList(query, "AccountId", "AccountName");
return PartialView("ItemPurchased", new List<PurchasedItem>());
}
##Controller##
public ActionResult GetPurchasedItem()
{
var optionsValue = this.Request.Form.Get("SupplierId");
return View();
}
答案 0 :(得分:0)
您可以尝试以下更改。
[HttpPost]
public ActionResult GetPurchasedItem(string SupplierId)
{
var optionsValue = SupplierId;
//..............
return View();
}
控制器将
I would suggest you to use
http://bootstrapdocs.com/v3.2.0/docs/components/#nav-tabs
for handling tabs functionality.
它应该正常工作..