473,396 Members | 1,671 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,396 software developers and data experts.

passing session variable from DDL

kai
Hi, All
I put Drop Down List on a ASP.NET form, it contains "CustomerID" from
Northwind Database from SQL Server 2000 "Customers" table. I use
SqlDataAdapter, SqlConnection and DataSet control to connect the
"ddlCustomerID" control. When I select a customerID from the list, let say
"BLONP",
and navigate to next page, it always point to first item on the list
"ALFKI". This is my code on "btnNext_Click" event:

Session("customerID")=ddlCustomerID.SelectedItem.V alue
Me.Response.Redirect("next.aspx")

On next.aspx page, I have Session("customerID")="ALFKI" all time. What is my
problem?

Thanks

Kai
Nov 18 '05 #1
2 1219
Kai,

My immediate guess is that you are rebinding the drop down on every post
back.

If this is the case that means that you need to use code like this:

If Not IsPostBack Then
'---Bind your drop down list here
End If

What is happening is that, when the page is loaded, you are rebinding the
drop down. That resets it's selected item to the first item in the list.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"kai" <ka******@earthlink.net> wrote in message
news:LI****************@newsread2.news.atl.earthli nk.net...
Hi, All
I put Drop Down List on a ASP.NET form, it contains "CustomerID" from
Northwind Database from SQL Server 2000 "Customers" table. I use
SqlDataAdapter, SqlConnection and DataSet control to connect the
"ddlCustomerID" control. When I select a customerID from the list, let say
"BLONP",
and navigate to next page, it always point to first item on the list
"ALFKI". This is my code on "btnNext_Click" event:

Session("customerID")=ddlCustomerID.SelectedItem.V alue
Me.Response.Redirect("next.aspx")

On next.aspx page, I have Session("customerID")="ALFKI" all time. What is my problem?

Thanks

Kai

Nov 18 '05 #2
kai
Justin ,
Thanks, it is exactly like you said, now I use your code fixed it.

Thanks

Kai
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:uB**************@TK2MSFTNGP09.phx.gbl...
Kai,

My immediate guess is that you are rebinding the drop down on every post
back.

If this is the case that means that you need to use code like this:

If Not IsPostBack Then
'---Bind your drop down list here
End If

What is happening is that, when the page is loaded, you are rebinding the
drop down. That resets it's selected item to the first item in the list.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"kai" <ka******@earthlink.net> wrote in message
news:LI****************@newsread2.news.atl.earthli nk.net...
Hi, All
I put Drop Down List on a ASP.NET form, it contains "CustomerID" from
Northwind Database from SQL Server 2000 "Customers" table. I use
SqlDataAdapter, SqlConnection and DataSet control to connect the
"ddlCustomerID" control. When I select a customerID from the list, let say "BLONP",
and navigate to next page, it always point to first item on the list
"ALFKI". This is my code on "btnNext_Click" event:

Session("customerID")=ddlCustomerID.SelectedItem.V alue
Me.Response.Redirect("next.aspx")

On next.aspx page, I have Session("customerID")="ALFKI" all time. What
is my
problem?

Thanks

Kai


Nov 18 '05 #3

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

Similar topics

5
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page...
1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
14
by: Antoni | last post by:
Hello, I wondered if anyone could offer some guidance over my php script. I was hoping the example would allow the user to click the submit buttons and the item number increment. And when the...
6
by: Rob Meade | last post by:
Hi all, At work we have 2 servers in a cluster for our web apps. One problem we have experienced (along with many others!) - is that if a user is logged into one of the applications on server...
4
by: Jason Us | last post by:
Does anyone have experience with passing variables from an ASP page to a JSP page. The way it currently works in passing the SSN in the URL. This cannot be good. I thought that storing a...
4
by: A Web Master | last post by:
I want to know the best way of passing on variable contents on a site coded in ASP using frameset/frame. Content is used in all frames for stuffs like screen_resolution, language, ... My...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
2
by: Roy | last post by:
Hey all, Is it possible to pass session variables between pages in separate projects? For example: inetpub\thisproject\blah.aspx has a session variable and response.redirects the user to...
1
SHOverine
by: SHOverine | last post by:
Recently my web host decided to "upgrade". This change rendered many of my pages useless and I am scrambling to fix the issues, so you may see several posts from me in the coming days. My first...
5
by: aelred | last post by:
I have a web page where a member can open up a chat window (child window) with another member. - From there the member can also navigate to other web pages. - From other pages in the site, they...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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...

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.