Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why are there more than three items in the dropdown list ?

Status
Not open for further replies.

chu2654

Programmer
Sep 16, 2005
5
TW
Hello, I have code as following. But there are more than three items in the drop downlist. What 's the problem ? (The dropdown list is 1,1,1,1,1,2,3,1,2,3,1,2,3)
<html>
<head>
<title>Ch6-3-5.aspx</title>
<script language="VB" runat="Server">
Sub Page_Load()
Ship.items.add("1")
Ship.items.add("2")
Ship.items.add("3")
End Sub
Sub button_Click(Sender As Object, e As Eventargs)

show.Text = Ship.SelectedItem.Text

End Sub
</script>
</head>
<body>
<p>Web - DropDownList</p><hr>
<form runat="Server">
<p></p>
<asp:DropDownList id="Ship" Width="100px" runat="Server">

</asp:DropDownList>
<asp:button id="Button" Text="send" OnClick="button_Click" runat="Server"/>
</form>
<asp:Label id="show" font-bold="true" runat="Server"/><br>
</body>
</html>
 
Try something like this. I think you are adding items every postpack

Sub Page_Load()

if not ispostback then
Ship.items.Clear() ' This may be wrong it may be Ship.Clear()
Ship.items.add("1")
Ship.items.add("2")
Ship.items.add("3")
end if

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top