This is all asp.net c#.
I have an enum
public enum ControlSelectionType { NotApplicable = 1, SingleSelectRadioButtons = 2, SingleSelectDropDownList = 3, MultiSelectCheckBox = 4, MultiSelectListBox = 5 }
The numerical value of this is stored in my database. I display this value in a datagrid.
<asp:boundcolumn datafield='ControlSelectionTypeId' headertext='Control Type'></asp:boundcolumn>
The ID means nothing to a user so I have changed the boundcolumn to a template column with the following.
<asp:TemplateColumn> <ItemTemplate> <%# Enum.Parse(typeof(ControlSelectionType), DataBinder.Eval(Container.DataItem, 'ControlSelectionTypeId').ToString()).ToString()%> </ItemTemplate> </asp:TemplateColumn>
This is a lot better… However, it would be great if there was a simple function I can put around the Enum to split it by Camel case so that the words wrap nicely in the datagrid.
Note: I am fully aware that there are better ways of doing all this. This screen is purely used internally and I just want a quick hack in place to display it a little better.
Indeed a regex/replace is the way to go as described in the other answer, however this might also be of use to you if you wanted to go a different direction
…
this will allow you define your Enums as
Taken from
http://www.codeguru.com/forum/archive/index.php/t-412868.html