Solved

Displaying Enums

Posted on 2006-11-20
7
240 Views
Last Modified: 2010-04-16
Here is my code...

public enum Priority
    {
        Low =1, Medium = 2, High = 3
    }


<asp:TemplateField HeaderText="Priority">
    <ItemTemplate>
        <%#(Eval("Priority")) %>
    </ItemTemplate>
</asp:TemplateField>

Right now the Priority displays as a number i.e., 1
I would like for it to display "Low" instead
0
Comment
Question by:JRockFL
7 Comments
 
LVL 29

Expert Comment

by:Nightman
ID: 17982547
Try Priority.ToString()
0
 
LVL 8

Author Comment

by:JRockFL
ID: 17982643
It still displays as an integer.
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17982668
Try removing the eval statement.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 8

Author Comment

by:JRockFL
ID: 17982690
I need the eval to display the data, this is for ASP.NET.

0
 
LVL 22

Expert Comment

by:_TAD_
ID: 17983401
All enums resolve to an integer representation.  The only reason an enum has a text value associated with it is to assist the developer.

If you really want the enum name, you'll need to use reflections to inspect the enum itself and then translate the result to a reflected text value
0
 
LVL 6

Accepted Solution

by:
e1v earned 500 total points
ID: 17985688
To get the name of an enum you can use Enum.GetName(type, value), like

Enum.GetName(typeof(Priority), 1) returns Low
0
 
LVL 8

Author Comment

by:JRockFL
ID: 17986873
e1v,

Thank you, that is exactly what I was looking for.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now