Solved

ASP.NET C# Databinding Enum

Posted on 2011-09-13
3
383 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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