using System.Collections.Generic;
namespace HelloWorldMvcApp
public class HomeController : Controller
public IEnumerable<Customer> Customers
return new List<Customer>
new Customer { CustomerId = 1, CustomerName = "Thor" },
new Customer { CustomerId = 2, CustomerName = "Iron Man" },
new Customer { CustomerId = 3, CustomerName = "Hawk Eye" }
public ActionResult Index()
ViewBag.CustomerId = new SelectList(Customers, "CustomerId", "CustomerName");
public ActionResult Submit(Customer customer)
ViewBag.CustomerId = new SelectList(Customers, "CustomerId", "CustomerName", customer.CustomerId);