Good morning comrades I am trying to filter the records by means of a dropdownlist but at the moment of clicking the button it only refreshes the page but does not do any search.
controller
public ViewResult Index(string estado, int? page)
{
var estados = db.Representantes.OrderBy(p => p.EstadosT.Name).Select(p => p.EstadosT.Name).Distinct();
if (!String.IsNullOrEmpty(estado))
{
representante = db.Representantes.Where(s => s.EstadosT.Name.Contains(estado));
}
ViewBag.EstadosT = new SelectList( estados);
return View(representante .ToList().ToPagedList(pageNumber, pageSize));
}
view
@using (Html.BeginForm ()) {
States: @ Html.DropDownList ("StatesT", "All")
}