Solved

ASP.NET C# Databinding Enum

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

778 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