Enum as the data source for drop-down list - ASP.NET

28. November 2007

I've been using enum's a lot lately. Here is another enum snippet for my snippet collection showing how to use an enum as the source for the items in a drop down.

enum myEnum {Jan, Feb, Mar};

DropDownList myDDL;

myDDL.DataSource = Enum.GetNames( typeof ( myEnum ) );

myDDL.DataBind();

snippets

Comments are closed