472,328 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 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 5589
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. ...
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...
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...
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,...
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...
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...
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...
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...
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...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

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.