Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > formatting Enums
 

formatting Enums

for say a Repeater, how do I format a data item that matches to an enum in my code?

for example:

td><%# Server.HtmlEncode(DataBinder.Eval(Container.DataItem,"type").ToString()) %></td>

will output the raw type,

but in my enum 1=Red, 2=Green, 3=Blue.

how do I output "Red" or "Green" or "Blue" and not the values 1,2 or 3.

px2  Friday, September 04, 2009 1:47 AM
To get the name of an enum item, call Enum.GetName.

http://msdn.microsoft.com/en-us/library/system.enum.getname.aspx
Michal Burger  Friday, September 04, 2009 3:47 PM
To get the name of an enum item, call Enum.GetName.

http://msdn.microsoft.com/en-us/library/system.enum.getname.aspx
Michal Burger  Friday, September 04, 2009 3:47 PM

You can use google to search for other answers

Custom Search

More Threads

• combobox lookup not from datasource
• blank datasource pane in form design view
• How do I Save the Changes Made in a DataGridView to the Connected Database?
• Arbitrary child controls of DataGridViewRow
• ListBox selection problem
• DateTimePicker Control question
• ArgumentOutOfRangeException when removing row from within RowsAdded event handler
• Force Databinding before the control gets into view
• How to edit objects using a datagrid and a bindingsource?
• VB.NET-BindingSource