我的 ASP.NET MVC4 应用程序中有两个部分视图-
[HttpGet]
public ActionResult Autocomplete_Search(string accountHead, List<LedgerModel> ledge)
{
if (!String.IsNullOrEmpty(accountHead)) {
ledge = (from u in db.LedgerTables
where u.AccountHead.Contains(accountHead) && u.FKRegisteredRecord == this.LoggedInUser.RegisterID
select new LedgerModel {
AccID = u.AccID,
Place = u.Place,
AccountHead = u.AccountHead,
DateAccountHead = Convert.ToDateTime(u.DateAccountHead) != null ? Convert.ToDateTime(u.DateAccountHead) : DateTime.Now
}).ToList();
return RedirectToAction("_ProductSearchList", ledge);
}
return View();
//return Json(ledge, JsonRequestBehavior.AllowGet);
}
和-
public ActionResult _ProductSearchList(List<LedgerModel> ledge) {
List<LedgerModel> ledger = null;
if (ledge != null) {
ledger = (from u in ledge
select new LedgerModel {
AccID = u.AccID,
Place = u.Place,
AccountHead = u.AccountHead,
DateAccountHead = Convert.ToDateTime(u.DateAccountHead) != null ? Convert.ToDateTime(u.DateAccountHead) : DateTime.Now
}).ToList();
return PartialView(ledge);
}
else {
return PartialView(ledge);
}
}
好的,现在当我通过文本框发送字符串时,AutoComplete_Search
会调用 Action。在重定向到另一个名为_ProductSearchList
我的方法时,我将ledge
listType 的对象发送到此方法。但它在动作的参数ledge
中显示为空。_ProductSearchList
然而,这个对象是一个列表类型并且包含记录。如何获取ledge
重定向到 action 的这个对象_ProductSearchList
?