Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 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 February 27th, 2004, 12:33 PM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default viewstate lost if dropdownlist databound

Can anyone explain why a dropdownlist is only able to manage its viewstate if the items are hardcoded? I set the dropdownlist's onSelectedIndexChanged event to a simple handler that sets a label to the selected value. Of course it is only bound if it's not a postback. There is nothing else on the page.

After an item is selected, the page reloads and the ddl is empty. If I then hit the back button, it shows my page with the item I selected in the ddl visible, but the label is not set, showing the handler was never called.

Can anyone think of any reason in the world why the handler would not be called?
 
Old February 27th, 2004, 04:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

How are you handling IsPostBack?

 
Old February 27th, 2004, 09:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

It sounds like you are adding the items only the first time the page loads. If not, try creating them everytime and see if that helps.

If thats not the case, some code would be useful to diagnose the problem.

J
 
Old February 28th, 2004, 12:18 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

kent -

The dropdownlist control *should* maintain the list of items regardless of how they are added (markup/hardcoded or runtime). If you are indeed binding the DDL only on a non-postback page_load then you should see expected behavior for the list and the onSelectedIndexChanged handler should be called when you change selection. Post your code for this part of it so we can see for sure that there isn't something vital missing.

With regards to the back button: when you hit the back button you are going back to the previous state of the page. That state was the first load of the page which populated the list. In this case you should certainly not see the selectedindexchanged event fire because you are going back in the history of the page. (Plus, in most cases the page isn't even being run again on the server because of the browser's cached version of the page.)

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old March 11th, 2004, 02:37 PM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, I figured out the problem and I am posting my solution just in case anyone else ever comes across this issue. Make sure the ASP Postback SERVICE is running. It's funny but I am not laughing.
 
Old March 15th, 2004, 04:43 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

There is an ASP postback service? Can you elaborate? I have never heard of such a thing.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Databound Dropdown fullingdale ASP.NET 2.0 Basics 2 June 20th, 2008 02:33 AM
asp databound dropdownlist kent ASP.NET 1.0 and 1.1 Basics 7 June 2nd, 2008 09:07 AM
VS2005 DataGridViewComboBoxColumn databound CloudDust Visual Basic 2005 Basics 4 October 12th, 2006 06:29 PM
databound headertemplate collie VB.NET 2002/2003 Basics 0 March 7th, 2005 10:31 AM
Databound List Box Kunkel VS.NET 2002/2003 2 November 7th, 2003 01:38 PM





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