In my MVC application, I need to add a dropdown that would show a list of domain names.
I already have a ViewModel that contains multiple properties. I am not sure w
In your ViewModel
public class ViewModelClass
{
public string DomainName { get; set; }
public IEnumerable DomainList
{
get
{
return GetDomainNames() //your method to get domain names
.Select(d => new SelectListItem() { Text = d, Value = d });
}
}
}
your strongly typed view
@model ViewModelClass
@Html.DropDownListFor(model => model.DomainName, Model.DomainList)