An enum type declaration defines a type name for a related group of symbolic constants. Enums aretypically used when for “multiple choice” scenarios, in which a runtime decision is made from a number ofoptions that are known at compile-time. Below is the simple declaration of enum type with Int32
enum UserType
{
Admin = 1,
Super User = 2,
Guest User = 3,
Executive = 4
}
Now when you want to Access your enums in Dropdown list box with prior values you can used it in like below….
DropdownList1.DataSource = System.Enum.GetValues(typeof(UserType));
DropdownList1.Databind();
Now whenever you want to get the value of enum Parse() method of the enum is useful so to get the value of enum below snippet will be helpful to you.
int intUserType = Convert.ToInt32(System.Enum.Parse(typeof(UserType), DropdownList1.SelectedItem.ToString());
Happy Programming.
Posted by vikasmehta