So I took some advice to create a DropDownListFor element in my view, which meant to create a model view called
MODEL
class StudentModelView.
I have two properties.
StudentID{get;set;}
IEnumerable<SelectListItem> SelectPeopleList { get;set;}
I get the list to populate nicely with this code
VIEW
@Html.DropDownListFor(x => x.StudentID, Model.SelectPeopleList,"--Select Students--", new Dictionary<string,object>{ {"class","dropdowns"},{"id","selectPeopleDDL"}})
//NEED A BUTTON TO SUBMIT
CONTROLLER
public ActionResult Index()
{
return View(new StudentModelView());
}
- What kind of button do I need to make it post
- After posting, how do I update my view to show the new filtered list? Am I missing a POST controller or just ajax? What’s the best approach?
You could do it all using jquery, but here is couple of pointers:
You should wrap your filter in a form:
the submit button is not a must, you could just use jquery to submit whenever the value of the dropdown changes
in your controller: