Problem populating drop down list from enum

Hello experts
I'm having problems creating a web control. Hopefully you can helps.
Basically the web control is a drop down list that suppose to be populated with values from Enum.
I used to do this with Windows formes and it worked but ASP.NET gives me blank drop down when the page is launched.
So.. the code behind the web control:
public partial class Controls_States : System.Web.UI.UserControl
{
    public enum States
    {
        AL, AK, AZ, AR, CA, CO, CT, DE, DC, FL, GA, HI, ID, IL, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC,
        ND, OH, OK, OR, PA, RI, SC, SD, TN, TX, UT, VT, VA, WA, WV, WI, WY, Canada, All
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ddlStates.DataSource = Enum.GetNames(typeof(States));
    }
}

When control used on the page it populates blank drop down list. What's wrong guys ?
LVL 1
techsuppoprtAsked:
Who is Participating?
 
Ashutosh VyasFounder, InitQubeCommented:
YOU FORGOT TO BIND IT. :)

protected void Page_Load(object sender, EventArgs e)
        {
            ddlStates.DataSource = Enum.GetNames(typeof(States));
            ddlStates.DataBind();
        }
0
 
techsuppoprtAuthor Commented:
ah sweet, it worked! Quick question though... Do I need to close any Data Binds for some reason at any point ?..Maybe when I switch to another page ?
( i'm learning )
0
 
Ashutosh VyasFounder, InitQubeCommented:
i dont think so
0
 
techsuppoprtAuthor Commented:
Thank you very much!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.