Question: I have an ASP.NET page with a drop down (asp:DropDownList) control. I also have a defined ENUM

```
Public Enum myEnumType As Integer
  A
  B
  C
End Enum

```

I want to define the "value" property of each asp:ListItem with one of the ENUM value (A,B,C represented as a string of course). I also want to assign the "text" value of each to be some unrelated string (e.g "dog","cat","ant"). 

I would like to use this syntax:

```
<asp:DropDownList ID="myCombo" runat="server">
  <asp:ListItem Text="cat" Value="<%= myEnumType.A.toString() %>" />
  <asp:ListItem Text="dog" Value="<%= myEnumType.B.toString() %>" />
  <asp:ListItem Text="ant" Value="<%= myEnumType.C.toString() %>" />
</asp:DropDownList>

```

But using the <%= is not valid in this type of controls.

How can I do this in declarative ASP.NET (not with code behind to create each item)

Answer: 
```
foreach(var item in Enum.GetValues(typeof(MyEnum)))
{
    lbEnum.Items.Add(new ListItem(Enum.GetName(typeof(MyEnum), item), item.ToString()));
}

```
Why not databind?

```
enum MyFavoriteEnum { A=1, B=2, C=3 }
for(int i =0; i<Enum.GetNames(typeof(MyFavoriteEnum)).Length;i++)
{
   ListItem li = new ListItem(
       Enum.GetNames(typeof(MyFavoriteEnum))[i],
       ((int)Enum.GetValues(typeof(MyFavoriteEnum)).GetValue(i)).ToString()
       );
    dropDown.Items.Add(li);
} 
// Edited to make it actually work

```