473,472 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

dropdownlist value not persisting after autopostback

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_SelectedIndex Changed"
autopostback="true">
<asp:ListItem value = "19">19</asp:ListItem>
<asp:ListItem value = "20">20</asp:ListItem>
</asp:DropDownList>
</form>
</body>
</html>
Nov 18 '05 #1
1 1440
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

"Daniel Doyle" <no****@please.com> wrote in message
news:OA**************@TK2MSFTNGP11.phx.gbl...
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_SelectedIndex Changed"
autopostback="true">
<asp:ListItem value = "19">19</asp:ListItem>
<asp:ListItem value = "20">20</asp:ListItem>
</asp:DropDownList>
</form>
</body>
</html>

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Daniel | last post by:
Is there any other way can override this event, like javascript onchange added to the attribute of this dropdownlist? Thanks
5
by: bryanp10 | last post by:
I have a page that is almost entirely dynamically created. Textboxes and checkbox are working fine, firing events, and persistent their state. DropDownList is giving me a major headache. All...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
0
by: asmx126453 | last post by:
Hey mensen I am having some big troubles here i tryd solving it myself with internet for 2 days but i kind fix it. Its about this i have a DotNet project that alrydi is online and working for...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.