Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 31st, 2009, 03:35 PM
Authorized User
 
Join Date: Jun 2009
Posts: 66
Thanks: 22
Thanked 0 Times in 0 Posts
Default How to retain selected values from dropdown list??

How to retain selected values from dropdown list?? Please help.

I have two DropDownLists databound on the webform. The autopostback of the first dropdown list control is set to true. The contents of the first dropdown list is hardcoded. The contents of the second depend on the selected item in the first. In other words: The selectedvalue of the first DropDownList is passed as a parameter for the query at the basis of the second DropDownList's datasource. And this works: Whenever I click on an item in the first DropDownList, the dependant items are shown in the second DropDownList.

If I click submit then the specific rows from the DB will be pulled based on the values selected from dropdown list 1 and dropdown list 2.

The second ddl is populated inside the postback method. SO everytime the page is postback/refreshed the default value gets selected.

Problem: as the postback method is called everytime the page is postback so it sets the value of ddl2.selectedValue="ANY" instead of selecting a specific value from the dropdown list 2. And that's why always all the values are pulled from the DB. Can anyone suggest any solution to that please please?
Thanks
 
Old August 31st, 2009, 08:46 PM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

have you tried storing values in a cookie and reading the cookie to determine what index should be selected
 
Old August 31st, 2009, 09:56 PM
Authorized User
 
Join Date: Jun 2009
Posts: 66
Thanks: 22
Thanked 0 Times in 0 Posts
Default

I don't know how to read a cookie and store a value inside a cookie. Can you please suggest something else....with the post back method?.....it's in the post back where the problem is, and how I am generating the values for the 2nd DDL. Please help.
Thanks in advance.
 
Old September 1st, 2009, 01:09 AM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

well... good luck
 
Old September 1st, 2009, 02:08 AM
Authorized User
 
Join Date: Apr 2008
Posts: 54
Thanks: 0
Thanked 4 Times in 4 Posts
Default

actually how did you bind the data. if it is in page load put the binding in the Not Postback. this will avoid reseting the selected value.
__________________
Pon Saravanan
VbKnowledgebase.com
The Following User Says Thank You to pons_saravanan For This Useful Post:
skhan (September 1st, 2009)
 
Old September 1st, 2009, 09:13 AM
Authorized User
 
Join Date: Jun 2009
Posts: 66
Thanks: 22
Thanked 0 Times in 0 Posts
Default

Thank you for your help. I have solved the problem. I have bounded the data inside the first dropdown list's OnSelectCheange event handler and took out the !Page.IsPostBack as I didn't need that anymore.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to highlight selected dropdown values. sheetm J2EE 0 June 5th, 2007 05:04 AM
How to retain form values from dependent list ? George B Javascript 0 September 15th, 2006 03:54 PM
SOS Retain values on SubmitText field and DropDown rabbit124 Classic ASP Basics 17 March 7th, 2006 07:15 PM
SOS: Retain values on Submit in Textfield,Dropdown rabbit124 Classic ASP Professional 1 March 7th, 2006 07:12 PM
Title: dropdown list as selected according to the san_only ASP.NET 1.x and 2.0 Application Design 1 June 4th, 2003 01:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.