Asp net gridview rowupdating e oldvalues
If you use this as the datasource for a control then the Selected Value returned by the control will be a string - and you will have to somehow convert this back to the enum value which will be messy.
Using the Type Converter approach, outlined in the article, the datasource is set to a list of the actual enum values.
One possibility would be to modify the Resource Enum Converter. Any extra guidance for using this technique within an MVVM scenario?
Get Value Text method so that instead of just using type. Full Name (ie the fully qualified name of the type). NET Localization made easy Infralution Licensing System - simple, secure and affordable licensing Virtual Tree - superfast, flexible, databound tree/list view For the first issue you're right, it works, don't know why, seemed to me like it wasn't working, sorry. Nice code though, and my vote of 5If you want to sort the display values in a Combo Box or List Box you can just set the Sorted property of the control to true. NET Localization made easy Infralution Licensing System - simple, secure and affordable licensing Virtual Tree - superfast, flexible, databound tree/list view extension method with a parameter to specify a different string format for the resource item, or pass it a different resource manager.
The resource keys should just be My Enum_Value_1 and My Enum_Value_2.
The second issue is only a problem if you want the translations to be different.
Additionally, I would like the detail Grid Views, which are "paged", to jump to the page where the... You would need to replace the "." in the fully qualified name with underscores. For the second, your consideration in correct, at the moment, i don't know if i want different translations. When the language is changed you have to reload the Data Source of the control (as the sample does anyway). It's a pity we don't have partial enums, otherwise you could overload To String() and not worry about the enum extension method.Eventually, your solution seems good to me, probably i will go for it. To add a special value you can simply add all the Enum values to a object collection (eg Array List) and insert a string for your special value at the top. The extension method is nice when you are accessing the Enum value in code (eg font Size.You could just use the same entries in the resource file for both enums ie you just would put entries: Both enums will then read the same entries.
If for some reason you need different text and/or translations for the same entry then you would have to consider a different approach. How would you add special values that may not be defined as part of the enum; am thinking of a Combo Box where the initial Selected Item might be something like "None" or "Select Gender" 3.So, I criticize your method based on these criteria, but not so much your work as the whole Microsoft's attribute's parameters comes in most ugly making possible bugs very hardly detectable. If someone is really interested in how the internals work - or building/customizing their own solution then I figure they can read the code (which I think is generally well internally documented) as you have done.