我正在尝试这样做:
public ActionResult Index(List<Client> Client)
{
if (Client != null)
return View(Client);
return View(db.Client.ToList());
}
[HttpPost]
public ActionResult Search(string cnpj)
{
List<Client> Client = db.Client // here it finds one client
.Where(c => cnpj.Equals(c.Cnpj))
.ToList();
return RedirectToAction("Index", Client);
}
动作搜索后,它转到索引,但客户端参数始终为空..
有人知道为什么吗?
我这样做并且工作:
public ActionResult Index(string cnpj)
{
if (!string.IsNullOrEmpty(cnpj))
{
List<Client> clients = db.Client
.Where(c => cnpj.Equals(c.Cnpj))
.ToList();
return View(clients);
}
return View(db.Client.ToList());
}