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

SQL SERVER – FIX : Error 3154: The backup set holds a backup of a database other than the existing database

SharePoint Close methods for SP Long Operations and Redirect Error Page