public ActionResult Index() { var model = new PostWholeFormExampleViewModel() { Message = "Hello", People = PeopleDropdownItems(), Pets = PetsDropdownItems(1) }; return(View(model)); }
public ActionResult Index(PostWholeFormExampleViewModel viewModel) { // Normally you would do some sort of validation to make sure the view // model that's been posted back is valid, i.e. the user hasn't dicked around with it too much. // The drop down options aren't posted back so reload them here. viewModel.Pets = PetsDropdownItems(viewModel.SelectedPersonId); viewModel.People = PeopleDropdownItems(); return(View(viewModel)); }