Posts

Showing posts with the label DataSource

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 ; }