Skip to content

Instantly share code, notes, and snippets.

@chalisegrogan
Created February 12, 2014 03:53
Show Gist options
  • Select an option

  • Save chalisegrogan/8949807 to your computer and use it in GitHub Desktop.

Select an option

Save chalisegrogan/8949807 to your computer and use it in GitHub Desktop.
Create ASP.NET Drop Down List from Enum
Public Enum MyEnum
ValueOne = 1
ValueTwo = 2
End Enum
Dim enumValues As Array = System.Enum.GetValues(GetType(MyEnum))
Dim enumNames As Array = System.Enum.GetNames(GetType(MyEnum))
For i As Integer = 0 To enumNames.Length - 1
Dim item As New ListItem(enumNames(i), enumValues(i))
ddlToPopulate.Items.Add(item)
Next
' Front end control: <asp:DropDownList ID="ddlToPopulate" runat="server" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment