Autopostback dropdownlists...

D

Dan Bass

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top