I have Search
searching by name, but wanted to search for both name and place in the same search field.
Follow the action:
[HttpPost]
public ActionResult Search(FormCollection fc, string searchString)
{
if (!String.IsNullOrEmpty(searchString))
{
var clientes = db.Locals.Include(c => c.Cidades).Include(e => e.Cidades.Estado).Where(c => c.Nome.Contains(searchString)).OrderBy(o => o.Nome);
return View("Index", clientes.ToList());
}
else
{
return RedirectToAction("Index");
}
}
In this var clientes
wanted to search beyond the name, search the city, and bring all of that city, I believe it is in where
itself, but I do not know ...
This is the search HTML:
@*Código de pesquisa*@
using (Html.BeginForm("Search", "Local", null, FormMethod.Post))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
<div class="col-md-10">
@* @Html.TextBox("SearchString")*@
Pesquisar: <input type="text" name="SearchString" id="SearchString" class="form-control" value="@ViewBag.Pesquisa" />
<input type="submit" value="Pesquisar" class="btn btn-default" />
</div>
</div>
</div>
}