dropdownlist value not persisting after autopostback

D

Daniel Doyle

I have cut my page down to the simple code below.
The problem is when the user selects a number from the list I want this
number to remain selected after the response.redirect, but the first item in
the list is always selected. I have another page that looks the same and
works but I can't understand why this one doesn't.
Please help.

Thanks. Dan.

<%@ Page Language="VB" %>
<script runat="server">

' Insert page code here
'

Private Sub Page_Load (sender As Object, e As System.EventArgs)

If (isPostBack = False) Then
GetRequiNums
Else
response.write ("nothing")
End If

End Sub


Sub GetRequiNums()

response.write ("get requi numbers")

End Sub


Private Sub cboRequiNums_SelectedIndexChanged _
(sender As Object, e As System.EventArgs)

Response.Redirect ("view_requi.aspx?RequiNum=" &
cboRequiNums.SelectedItem.Value)

End Sub

</script>
<html>
<head>
</head>
<body>
<form id="requi_view" runat="server">
<asp:dropdownlist class="dropdownstyle" id="cboRequiNums" runat="server"
width="405" onSelectedIndexChanged="cboRequiNums_SelectedIndexChanged"
autopostback="true">
<asp:ListItem value = "19">19</asp:ListItem>
<asp:ListItem value = "20">20</asp:ListItem>
</asp:DropDownList>
</form>
</body>
</html>
 
S

Steve Caliendo

Then you must use a session variable or db entry. When the page redirects
all of the view state data is gone - If you would like maintain the value of
your list then stuff it into a session variable that can be checked when the
page reloads.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top