Double dropdown dilemma - Server vs client

D

Don Parker

I want to have 2 dropdowns - one containing categories of items such as
Furniture, Applicances etc. The other dropdown is a list of
subcategories that match the first drop down. So if the user chooses
Furniture - the 2nd dropdown will show Bed, Sofa etc - or if they choose
applicances they will see refrigerator, range, dryer etc. What is the
best way to do that? I was thinking to use a dataset a view and just
filter the view and bind it to the dropdown - but I'm thinking you can't
do that in client script. I don't want to make a round trip back to the
server every time they choose a different category - but if I must - I
don't want to reload the whole page. In the old days I would use RDS or
remote scripting to make a call to the database without loading the page
again. How does one do that in this new world of ASP.NET?
 
E

Eliyahu Goldin

A pure client solution, no roundtrips.

Make a hidden repeater with itemtemplate including just one ddl. Bind the
repeater to the table with categories. In ItemDataBound event populate the
ddl for every category with subcategories. Hide the repeater with css rule
display:none rather than with Visible=false.

In this way you preset all ddls and pass them to client. Make separate
visible ddls for categories and subcategories, the ones users will select
from. On category change, loop through the DHTML presentation of the hidden
repeater, find the row for the category and copy the ddl items from that row
to the visible subcategory ddl.

Eliyahu
 

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

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top