For some reason I\'m stuck on this. I need to filter results from a View based on a DropDownList in the same view. The basic idea is this: I have a list of providers that be
To add upon the earlier answers.
To create a drop down (in ASP .NET MVC 3) I did the following:
Add code to Index.cshtml
@using (Html.BeginForm())
{
@Html.DropDownList("EmployeeId", (SelectList)ViewData["EmployeeId"])
}
Add code to YourModelNameController.cs in the default ActionResult for Index()
public ActionResult Index()
{
//create a selectlist
var employeeList = from el in db.Employee select el;
ViewData["EmployeeId"] = new SelectList(employeeList, "EmployeeId", "TmName");
return View(modelName);
}