[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Displaying Enums

Posted on 2006-11-20
7
Medium Priority
?
255 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 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