Author: mm8 | Posted on: 7/12/2008 4:17:40 AM | Views : 571

I'have an Enum and a want to populate a DDL with it like this...:

In the Business object:
public enum MyRoles
{
RoleOne = 1,
...
}

public void CreateRoleList(DropDownList ddl)
{
ddl.DataSource = BindToEnum(typeof(MyRoles));
}

private System.Collections.Hashtable BindToEnum(Type enumType)
{
// get the names from the enumeration
string[] names = Enum.GetNames(enumType);
// get the values from the enumeration
Array values = Enum.GetValues(enumType);
// turn it into a hash table
System.Collections.Hashtable ht = new System.Collections.Hashtable();
for (int i ...

Go to the complete details ...