Problem populating drop down list from enum
Posted on 2007-07-31
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 ?