[Solved] Languages drop down menu in MVC [closed]

There are lots of ways to do it, I have done this in the past by creating a specific class to wire up my values:

public class LanguageItem
    public bool Disabled { get; set; }
    public string Value { get; set; }
    public string Name { get; set; }

Then you can create your property in your model as:

public IEnumerable<LanguageItem> Languages
         return new List<LanguageItem>
              new LanguageItem {Name = "English", Value = "en-US"}

or however you populate yours. Create a field for the selection (i.e. SelectedLanguage). Then something like…

 @Html.DropDownListFor(m => m.SelectedLanguage, new SelectList(Model.Languages, "Value", "Text"), "Language")

Should work


solved Languages drop down menu in MVC [closed]