Home
Manage Your Code
Snippet: Enum to DropDownList (C#)
Title: Enum to DropDownList Language: C#
Description: Read an Enum in a DropDownList with the correct value Views: 413
Author: Fabrizio Antonangeli Date Added: 5/12/2008
Copy Code  
1        string[] Names;
2
3        Names = Enum.GetNames(typeof(TypePage));
4
5
6        IdTypePageDropDownList1.Items.Clear();
7
8        for (int i = 0; i < Names.Length; i++)
9        {
10            IdTypePageDropDownList1.Items.Add(new ListItem(
11                                                            Names[i],
12                                                            ((int)Enum.Parse(typeof(TypePage), Names[i])).ToString()
13                                                            )
14                                             );
15        }