Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp: dropdownlist

Status
Not open for further replies.

dhmfh

Programmer
Nov 28, 2005
69
GB
Hi guys

I have a asp:dropdownlist control that is databinded. When I change the value it posts back and displays the selected value. When I click the search button it re-directs to another page and i lose the selected value. Any ideas of how not to lose this value
 
Pass it through to the second page as a session variable, a querystring or use Server.Transfer.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
If you do not want to store data in the session, you could create the hyperlink you want to post to in the SelectedIndexChanged event handler of the drop down list. Then include the selected id in the hyperlink and access it in the page you are redirecting to:

eg:

int id = int.Parse( DropDownList1.SelectedItem.Value );
string url = "myUrl.aspx" + id.ToString();

Response.Redirect( url, true );

Page you are directing to:

int id = int.Parse( Request.QueryString[ "id" ] );

Hope this helps.

 
Thanks guys for these points.

On another note I am using a nested repeater that binds data through a relation to the dataset. Do you know how to reference values from the child repeater?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top