Put in Index File…
<p>
@using (Html.BeginForm(“Index”, “Department”, FormMethod.Get)) {
<b>Search By:</b>@Html.RadioButton(“searchBy”, “search”,true)<text>Name</text>
@Html.TextBox(“search”)<input type=”submit” value=”search” />
}
</p>
<p>
@using (Html.BeginForm(“Index”, “Department”, FormMethod.Get)) {
<b>Search By:</b>@Html.RadioButton(“searchBy”, “search”,true)<text>Name</text>
@Html.TextBox(“search”)<input type=”submit” value=”search” />
}
</p>
—DepartmentController
public ActionResult Index(string searchBy, string search)
{
if (searchBy == “Name”)
{
return View(db.Departments.Where(x => x.DprtName.StartsWith(search)).ToList());
}
else
{
return View(db.Departments.Where(x => x.DprtName.StartsWith(search)).ToList());
}
}