[HttpPost] public ActionResult Search( string Search) { var emp = from m in db.Emps select m; if (emp != null) { var ttt = db.Emps.Where(s => s.Name.Contains(Search)); } else { ModelState.AddModelError("Name"," No records found"); } return View(emp); }
@using (Html.BeginForm("Search", "Emps", FormMethod.Post)) { <div class="container form-group"> <input class="form-control" type="text" id="Mail" name="Search"> </div> @*@Html.TextBox("SearchText")*@ <div class="form-group"> <input type="submit" value="Search" id="searching" class="btn btn-default mysquare" /> </div> } @if (Model != null) { foreach (var person in Model) { <tr> <td> @Html.DisplayFor(modelitem => person.ID) </td> </tr> <tr> <td> @Html.DisplayFor(modelitem => person.Name) </td> </tr> <tr> <td> @Html.DisplayFor(modelitem => person.City) </td> </tr> <tr> <td> @Html.DisplayFor(modelitem => person.Designation) </td> </tr> <tr> <td> @Html.DisplayFor(modelitem => person.Country) </td> </tr> <tr> <td> @Html.DisplayFor(modelitem => person.Mail) </td> </tr> } }
var foundEmployees = db.Emps.Where(s => s.Name.Contains(Search)); if(foundEmployees == null) ModelState.AddModelError("Name"," No records found"); return foundEmployees;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)