我试图这样做:
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());
}