Bind dropdownlist to enum

public static ListItemCollection GetListItemsFromEnum(Type enumType)
        {

            ListItemCollection items = new ListItemCollection();

            string[] names = Enum.GetNames(enumType);
            Array values = Enum.GetValues(enumType);

            for (int i = 0; i <= names.Length - 1; i++)
            {
                items.Add(new ListItem(names[i], values.GetValue(i).ToString()));
            }

            return items;
        }

Comments

Popular posts from this blog

How to remove app from SharePoint 2013/2016

The model backing the context has changed since the database was created. Consider using Code First Migrations to update the database