I'm trying to do this:
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);
}
After action Search, it goes to Index, but the Client parameter is always null..
Someone knows why?
I do it and works:
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());
}