Drop down items missing after postback
Posted on 2007-11-30
This sounds like a dumb questions even as I am writing it, but I am adding items to a drop down list in the OnLoad. The dropdown has autopost back enabled. When I run it the app on the webserver and change the year in the drop down list the items I added dynamically disappear. When I am debugging, they don't disapper.
<asp:DropDownList ID="ddlYears" runat="server" AutoPostBack="true">
For i As Int32 = DateTime.Now.Year - 1 To (DateTime.Now.Year + 2)
Dim ddlEntry As New ListItem(i.ToString(), i.ToString())
If i = DateTime.Now.Year Then
ddlEntry.Selected = True