Solved

Displaying Enums

Posted on 2006-11-20
7
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ado.net AddWithValue when using IN condition 7 44
C# MVC Insert Multiple Row into DB 2 95
Converting PHP triple des decrypt to c# 9 162
asp.net, radiobuttonlist, c# 3 68
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

732 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