hpl
Jan 8th, 2003, 02:53 AM
I have a quit simple question. I have to drpdwnlsts, I wish to sort the content of drp2 by the way I choose in 1.
My code is:
<%@ Page Language="vb" %>
<script runat="server">
public Sub Page_Load()
if not page.isPostback then
Dim AnimalArray(4) As String
Dim strAnimal As String
AnimalArray(0) = "Dog"
AnimalArray(1) = "Cat"
AnimalArray(2) = "Elephant"
AnimalArray(3) = "Lion"
AnimalArray(4) = "Cat"
Dim SortArray(2) As String
Dim strSort As String
SortArray(0) = "Reverse"
SortArray(1) = "Forward"
SortArray(2) = "Alphabethical"
For Each strAnimal In AnimalArray
MyDropDownList.Items.Add(strAnimal)
Next
For Each strSort In SortArray
MyDropDownList2.Items.Add(strSort)
Next
end if
End Sub
public Sub SortAnimal(sender As Object, E As Eventargs)
Dim SortVal as string
sortval = MydropDownList2.selectedItem.Value
if sortval = "Reverse" then
'array.reverse(animalArray)
end if
end sub
</script>
<html>
<head>
<form id="Form1" method="post" runat="server">
<asp:dropdownlist id="MyDropDownList2" OnSelectedIndexChanged="sortAnimal" AutoPostBack="true" runat="server"></asp:dropdownlist>
<asp:dropdownlist id="MyDropDownList" runat="server"></asp:dropdownlist>
</form>
</head>
<body>
</body>
</html>
My code is:
<%@ Page Language="vb" %>
<script runat="server">
public Sub Page_Load()
if not page.isPostback then
Dim AnimalArray(4) As String
Dim strAnimal As String
AnimalArray(0) = "Dog"
AnimalArray(1) = "Cat"
AnimalArray(2) = "Elephant"
AnimalArray(3) = "Lion"
AnimalArray(4) = "Cat"
Dim SortArray(2) As String
Dim strSort As String
SortArray(0) = "Reverse"
SortArray(1) = "Forward"
SortArray(2) = "Alphabethical"
For Each strAnimal In AnimalArray
MyDropDownList.Items.Add(strAnimal)
Next
For Each strSort In SortArray
MyDropDownList2.Items.Add(strSort)
Next
end if
End Sub
public Sub SortAnimal(sender As Object, E As Eventargs)
Dim SortVal as string
sortval = MydropDownList2.selectedItem.Value
if sortval = "Reverse" then
'array.reverse(animalArray)
end if
end sub
</script>
<html>
<head>
<form id="Form1" method="post" runat="server">
<asp:dropdownlist id="MyDropDownList2" OnSelectedIndexChanged="sortAnimal" AutoPostBack="true" runat="server"></asp:dropdownlist>
<asp:dropdownlist id="MyDropDownList" runat="server"></asp:dropdownlist>
</form>
</head>
<body>
</body>
</html>