Alternatives
Members may post updates or alternatives to this current article in order to show different
approaches or add new features.
16 Jan 2013Sheikh Muhammad Haris
Hi,Try the following code [HttpGet]public ActionResult Index(){ ViewBag.CitiesDropDown = GetCityList(); return View();}private List GetCityList(){ //Here you can access DB to get your required data. Just make sure the return type ...
16 Jan 2013devdev13 3 alternatives
I have created the below drop-down to populate a list of cities.All works fine, but I would like to know the better ways of doing this please. Also, please let me know if it is possible to create the same drop down using instead of HTML helpers.Below are my DTO classes. Please...
You have several ways to do this. You don't even need to use ViewBag. Please look at my recent article: Dynamic tabular input with unobstructive validation in ASP.NET MVC3[^] (:)). It covers this scenario also.SelectListItem is useful if you generate your element on the fly, Selected has to...