Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Autopostback dropdownlists... (http://www.velocityreviews.com/forums/t779896-autopostback-dropdownlists.html)

Dan Bass 05-18-2007 10:46 AM

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.

Peter Bromberg [C# MVP] 05-18-2007 11:26 AM

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 01:19 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.