views:

23

answers:

1

i need to display the name of enum in gridview by data table returns its numeric value

i am using this for other columns

<asp:BoundField DataField="Name" HeaderText="User Name" /> 

i need to use it for enum to display the string value of enum Gender

<asp:BoundField DataField="Gender" HeaderText="Gender" /> 
+1  A: 

Try this solution

Enum.GetName Method

<asp:TemplateField HeaderText=”Category”>
<ItemTemplate>
<div>
<%# Enum.GetName(typeof(GlobalLibrary.Constants.Category),Convert.ToInt32(Eval(“Category”))) %>
</div>
</ItemTemplate>
</asp:TemplateField>
Pranay Rana
i am trying something like this<asp:BoundField DataField="<% # Enum.GetName(typeof(AR_Order.OrderType), Convert.ToInt32(Eval('OrderType'))) %>" HeaderText="Order Type">but not wrking infact
vakas
check updated answer its working for me
Pranay Rana
Thanx man its wrking ... with templatefieldi was using boundfield,dnt knw y the same thing not wrking there
vakas