Created
February 12, 2014 03:53
-
-
Save chalisegrogan/8949807 to your computer and use it in GitHub Desktop.
Create ASP.NET Drop Down List from Enum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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