Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design 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 6th, 2008, 12:33 AM
Registered User
Join Date: Feb 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Phantom Databinding on drop down list

I have converted a project from ASP.net 1.1 to 2.0 using Visual Studio 2008. I had not touched this code for two years and am having a ton of problems with it. The conversion was successful according to the wizard and it backed up the project in a "backup" folder.
On the front page I have two drop down lists. One called Projects and the other Branches, each is bound to a table in a database using Datareaders. When the "Projects" drop down is changed part of it's query pulls in a BranchID and is supposed to set the Branches drop down to that value.

However each time I change the Projects drop down I get an error that says that the value of the BranchID is outside the range:

dlstBranches has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

Stack Trace
[ArgumentOutOfRangeException: 'dlstBranches' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value]
   System.Web.UI.WebControls.ListControl.set_Selected Value(String value) +1827626
   Urgent.PP_New.dlstProject_SelectedIndexChanged(Obj ect sender, EventArgs e) +1069
   System.Web.UI.WebControls.ListControl.OnSelectedIn dexChanged(EventArgs e) +105
   System.Web.UI.WebControls.DropDownList.RaisePostDa taChangedEvent() +134
   System.Web.UI.WebControls.DropDownList.System.Web. UI.IPostBackDataHandler.RaisePostDataChangedEvent( ) +7
   System.Web.UI.Page.RaiseChangedEvents() +117
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1646

So I checked the databinding code for the Branches drop down and I found that it is being declared somewhere besides the PageLoad event. And thus the values are wrong. I even commented out the binding code in the PageLoad and still the Branches drop down was populated when I ran the page.

Is there something I'm missing? I checked the "designer.vb" file and I didn't see any binding code in there. Where else would it be looking? I am at a loss.

I tried putting a SQLDataSource on the page and binding the Branches drop down to that but it came back with the error that the Datasource and DataSourceID propterties were both being set and that I should only set one.

Thanks for any help you can give.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Usercontrol dropdown list databinding forkhead ASP.NET 1.0 and 1.1 Professional 14 February 12th, 2008 02:01 AM
Drop down list carumuga Classic ASP Basics 1 February 6th, 2007 02:37 PM
drop down list values based on another drop down noor ASP.NET 1.0 and 1.1 Basics 3 July 5th, 2005 09:57 AM
Drop Down List mrideout BOOK: Beginning ASP.NET 1.0 6 March 18th, 2005 03:32 AM
Drop Down List mrideout BOOK: Beginning ASP.NET 1.0 8 September 16th, 2004 07:11 AM

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