![]() |
Autopostback dropdownlists...
Greetings!
I've two dropdownlists where each has its own sqldatasource object as a datasource. The first, for example, contains a list of car manufacturers... BMW, Audi, Peugeot, Ford, etc... The second then changes to the viable models based on the selection of the first dropdown selection. So if the user selects BMW, then it displays '116, 118d, 118, 120, 316... etc'. Grand, peace of cake. Now, I save this data to a database and allow the users to load up the form later on. The problem is, I populate and select the loaded item from first dropdownlist (in Page_Load), but this doesn't populate the second dropdownlist with the sublist as would happen on an autopostback. So in our example, BMW is selected from the dropdownlist, but this doesn't then refresh the query on the 2nd sqldatasource or dropdownlist to see models in the BMW range. I've tried called DataBind, but this doesn't seem to do anything. Hope this isn't too muddy. Any help is appreciated. Thanks. Dan. |
RE: Autopostback dropdownlists...
Well. the problem is that if the 2nd SqlDataSource has a query tha is only
designed to populate all the items, then it will be too "Dumb" to know what to do when an item is selected from the first guy. During the SelectedIndexChanged event of the first, you need specific code to set the selected item on the second, or bring in fresh data and databind it so it matches the ID of the item selected from the first guy. Peter -- Site: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com Short urls & more: http://ittyurl.net "Dan Bass" wrote: > Greetings! > > I've two dropdownlists where each has its own sqldatasource object as a > datasource. > > The first, for example, contains a list of car manufacturers... BMW, Audi, > Peugeot, Ford, etc... > The second then changes to the viable models based on the selection of the > first dropdown selection. So if the user selects BMW, then it displays > '116, 118d, 118, 120, 316... etc'. > > Grand, peace of cake. > > > Now, I save this data to a database and allow the users to load up the form > later on. The problem is, I populate and select the loaded item from first > dropdownlist (in Page_Load), but this doesn't populate the second > dropdownlist with the sublist as would happen on an autopostback. So in our > example, BMW is selected from the dropdownlist, but this doesn't then > refresh the query on the 2nd sqldatasource or dropdownlist to see models in > the BMW range. I've tried called DataBind, but this doesn't seem to do > anything. > > > Hope this isn't too muddy. Any help is appreciated. > Thanks. > Dan. > |
| All times are GMT. The time now is 09:19 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.