Again : Enums as source of NameValueListAgain : Enums as source of NameValueList
Old forum URL: forums.lhotka.net/forums/t/7860.aspx
saeedsamie posted on Friday, October 23, 2009
Hi,
I looked up in the forum and I found a good way for producing a NameValueList based on an Enum type and using [Description("friendly string")] attribute for displaying purposes. But for a multilingual application I need to use resource files for replacing "friendly string" appropriately. The problem is that when I make a reference to the resource file for getting the string I need I recieve a compilation error that says : "An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type ".
Does anybody has a soluton for it?
sixeyes replied on Friday, October 23, 2009
This is what we used:
http://www.codeproject.com/KB/cs/LocalizingEnums.aspx
It's automatic if you're using WinForms but if you're using ASP.NET (we were) you need a couple of lines to force type converters.
Iain
saeedsamie replied on Friday, October 23, 2009
Hi Iain,
It was very helpful.
Thanks
Copyright (c) Marimer LLC