using System.Collections.Generic;
namespace HelloWorldMvcApp
public class HomeController : Controller
public ActionResult Index()
var list = new List<StateViewModel>()
new StateViewModel(){ Id = 1, Name = "Alabama", Station = "AL"},
new StateViewModel(){ Id = 2, Name = "Mississippi", Station = "MS"},
new StateViewModel(){ Id = 3, Name = "Georgia", Station = "GA"},
new StateViewModel(){ Id = 4, Name = "Florida", Station = "FL"}
ViewBag.Message = "Select some states";
var model = new StateListViewModel();
public ActionResult Index(StateListViewModel model)
var message = new StringBuilder();
message.AppendLine("Selected States<br>");
model.States.ForEach(a => {
message.AppendLine(string.Format("{0} {1}<br>", a.Name, a.Station));
ViewBag.Message = message.ToString();
var list = new List<StateViewModel>()
new StateViewModel(){ Id = 1, Name = "Alabama", Station = "AL"},
new StateViewModel(){ Id = 2, Name = "Mississippi", Station = "MS"},
new StateViewModel(){ Id = 3, Name = "Georgia", Station = "GA"},
new StateViewModel(){ Id = 4, Name = "Florida", Station = "FL"}