I am a newb to MVC programming. I am passing values from other db tables to my edit and create views to populate some dropdownlists. It's working great. I have code like this in my controller for edit and create:
var db = new MyProgramDataContext(); Order order = orderRepository.GetOrder(id); ViewData["customer"] = from c in db.customers select new SelectListItem { Text = c.customer_name, Value = c.customer_name } return View(order);
I want to move the select statement to the Respository to make things a bit cleaner so that I'm not repeating the same selects in Edit and Create.
ViewData["customer"] = orderRepository.GetCustomers();
In the Respository, should the return type of GetCustomers be SelectListItem? I can't seem to get it to work.