473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Page Post Back -- how to retain selecteditem.value of TWO dropdowns???

Hi,

On Page Load (if not postback), the user selects a choice from
dropdownlist1.

On SelectedItemChanged for dropdownlist1, dropdownlist2 is populated
and the user selects an item.

I cannot find a combination where I can RETAIN both values during
postback...if I put if not posback on the change event of
dropdownlist1, it doesn't populate #2...

Any help appreciated!

Kathy
Nov 17 '05 #1
6 5642
What does your event handler for SelectedItemChanged for dropdownlist1 look
like?

Todd Thompson
Nov 17 '05 #2
Here are both pageload and selecteditemchanged...when I load the page,
it let's me select the Customer (control 1), and DOES filter the second
control, but at the same time, resets control 1 to "Select
Customer"...ugh.

Both controls set to autopostback and enable viewstate.

Any ideas?

Thanks.
KathyBurke

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

If Not IsPostBack Then
Dim Conn1 As OleDbConnection
Dim Rdr1 As OleDbDataReader
Dim Cmd1 As OleDbCommand
Dim strSQL As String
Conn1 = New OleDbConnection(strConn)
strSQL = "SELECT DISTINCT Customer FROM tblCustomers ORDER
BY Customer"
Cmd1 = New OleDbCommand(strSQL, Conn1)
Conn1.Open()
Rdr1 = Cmd1.ExecuteReader()
cboCust.DataSource = Rdr1
cboCust.DataBind()
cboCust.Items.Insert(0, "Select Customer")
cboCust.SelectedIndex = 0
Rdr1.Close()
Conn1.Close()
End If

End Sub

Private Sub cboCust_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cboCust.SelectedIndexChanged

Dim Conn2 As New OleDbConnection()
Dim Rdr2 As OleDbDataReader
Dim strSQL2 As String = "SELECT Assy FROM tblAssy WHERE
([Customer] = @customer) ORDER BY Assy"
Dim Cmd2 As New OleDbCommand(strSQL2, Conn2)
Conn2 = New OleDbConnection(strConn)
Dim prmCustomer As OleDbParameter = New
OleDbParameter("@customer", OleDbType.VarChar, 50)
prmCustomer.Value = cboCust.SelectedItem.Value
Cmd2.Parameters.Add(prmCustomer)
Cmd2.Connection = Conn2
Conn2.Open()
Rdr2 = Cmd2.ExecuteReader()
cboAssy.DataSource = Rdr2
cboAssy.DataBind()
cboAssy.Items.Insert(0, "Select Assembly")
cboCust.SelectedIndex = 0
Rdr2.Close()
Conn2.Close()
End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #3
In your handler you have the following line:
On 27-Jun-2003, Kathy Burke <an*******@devdex.com> wrote:
cboCust.SelectedIndex = 0

If I'm understanding your code and problem correctly, you are setting the
index of the drop down to the first item instead of leaving it set to its
previous value.
Todd Thompson
Nov 17 '05 #4
You are correct in that the code contained within the Page_Load function and
in the IF NOT POSTBACK conditional won't be run.

But in your event handler cboCust_SelectedIndexChanged, you are setting the
cboCust.SelectedIndex=0 which will affect that drop down on the current
page.

Todd Thompson
Nov 17 '05 #5
Todd,

I'm an idiot...I copied the code for cboAssy but forgot to change that
control ref...THANK YOU...

KathyBurke

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #6
Kathy,

No problem, I've done the same thing myself.

Glad to be of help.

Todd
Nov 17 '05 #7

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

Similar topics

0
by: Pat Patterson | last post by:
I'm having serious issues with a page I'm developing. I just need some simple help, and was hoping someone might be able to help me out in here. I have a form, that consists of 3 pages of...
4
by: Justin Bartels | last post by:
Hi, I have been struggling with an unusual problem with a dropdownlist web control for quite some time now. Cutting straight to the problem, I am setting the selected item in the dropdownlist...
0
by: Goober at christianDOTnet | last post by:
I'm wanting to fix the following on a web page without really re-inventing anything. What I have is a vb web page with a radiobuttonlist where I can pick Current or History year. Underneath...
2
by: macyp | last post by:
I have to pass values from one aspx page to another. The controls I have in the first page are: a textbox, 3 drop down lists, and 2 check boxes, and a submit button. It is a search page, and the...
1
by: Stimp | last post by:
I have 2 dropdowns, county and district. When the county changes, I want the district dropdown to automatically update with a list of districts in that county, but I don't want the page to have...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
7
by: surikumarvinod | last post by:
hello, I have a page in wich i have 3 dropdowns and a grid view. when i click on the edit button in grid view to update a record it takes me to edit page. what i want is when i come back from...
5
by: Hans Kesting | last post by:
Hi, Is there good information about the asp.net page lifecycle in combination with dynamically loaded controls? Or on "how to build dynamic controls"? I keep hitting problems where values are...
2
by: qwedster | last post by:
Folks! The following is a "Hello World" kind of code for ViewState. I just want to know how to retain the ViewState 1) while Page Refresh when using UpdatePanel and also 2) While I reverting back...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.