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 :-)
views:
362answers:
2
A:
It really depends on how you have the values saved in the RESX. Let's just say you have the values saved as a string.
App_GlobalResources/Messages.resx:
Name | Value --------------------- title | Mr.,Mrs.,Ms.
List<SelectListItem> items = new List<SelectListItem>();
foreach (string s in Resources.Messages.title.Split(new char[] { ',' }))
{
items.Add(new SelectListItem() { Text = s, Value = s });
}
Response.Write(Html.DropDownList("Title", items));
+3
A:
This works for me
Html.DropDownList("ResxDropDownList",
new SelectList(
Resources.YourResource.ResourceManager.GetResourceSet(
System.Globalization.CultureInfo.CurrentCulture,
true,
true
),
"Key",
"Value"
)
)
n26
2009-07-21 09:38:18
thanks! this works exactly as expected
jao
2009-07-21 09:48:57