Solved

ASP.NET C# Databinding Enum

Posted on 2011-09-13
3
389 Views
Last Modified: 2012-05-12
is it possible to databind the values af an Enum?

Something like this:

public enum BlahEnum
    {  
        Red,
        Green,
        Blue,
        Purple
    }


this.ComboBox2.DataSource = BlahEnum;
this.ComboBox2.DataBind();

abd the combobox displays the item values like Red, Green, Blue, Purple
0
Comment
Question by:conrad2010
[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
3 Comments
 
LVL 15

Assisted Solution

by:Minh Võ Công
Minh Võ Công earned 167 total points
ID: 36533559
0
 
LVL 7

Accepted Solution

by:
dimaj earned 167 total points
ID: 36533574
Try this:

comboBox1.DataSource = Enum.GetNames(typeof(BlahEnum));
0
 
LVL 14

Assisted Solution

by:nishant joshi
nishant joshi earned 166 total points
ID: 36533835
public enum BlahEnum
{
    Today,
    Last7
    Last14,
    Last30,
    All
}

ComboBox combo = new ComboBox();

combo.DataSource = Enum.GetValues(typeof(BlahEnum));





http://www.codeproject.com/KB/cs/enumdatabinding.aspx

this might helps for more detail...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

627 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