Sort array elements and add them to the asp:dropdownlist (VB.net)
<%@Page language="vb" %>
<script runat="server" language="vb">
Sub Page_Load()
Dim AnimalArray(4) As String
Dim strAnimal As String
AnimalArray(0) = "Dog"
AnimalArray(1) = "Cat"
AnimalArray(2) = "Elephant"
AnimalArray(3) = "Lion"
AnimalArray(4) = "Cat"
Array.Sort(AnimalArray)
For Each strAnimal In AnimalArray
MyDropDownList.Items.Add(strAnimal)
Next
End Sub
</script>
<html>
<form id="Form1" method="post" runat="server">
<asp:dropdownlist id="MyDropDownList" runat="server" />
</form>
</html>