Search code examples
asp.net-mvcresourcesdrop-down-menuresx

Is there a way to dynamically populate a drop down list with values from a resource file?


So I have this .resx file and I want its values shown in a drop down list in ASP.NET MVC (C#). Is this possible? Google couldn't help me, so I hope SO can :-)


Solution

  • This works for me

    Html.DropDownList("ResxDropDownList",
        new SelectList(
            Resources.YourResource.ResourceManager.GetResourceSet(
                System.Globalization.CultureInfo.CurrentCulture,
                true,
                true
            ),
            "Key",
            "Value"
        )
    )