public ActionResult DropDown() { PartsViewModel partsViewModel = new PartsViewModel(); //Get list of options utility utility = new utility(); var sortOptions = utility.GetOptions(); //DropDownList property of view model will contain a list of all options. partsViewModel.DropDownList = utility.SetOptions(sortOptions); return(View(partsViewModel)); }
public ActionResult DropDown(PartsViewModel partsViewModel) { if (ModelState.IsValid) { { //'PartsViewModel.DropDownValue' property will contain your selected value //Do your stuff with this value such as DB update, etc } //Get list of options utility utility = new utility(); var sortOptions = utility.GetOptions(); //DropDownList property of view model will contain a list of all options. partsViewModel.DropDownList = utility.SetOptions(sortOptions); } return(View(partsViewModel)); }