Click here to Skip to main content
15,906,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've been going back and forth on whether to query a database for data on the client side or the code behind and I'm wondering if anyone has any info on the best way and possibly examples.

This is what I'm wanting to do:

I have a list box of columns that the user can select and 2 dropdown objects.

I want the selected values from the list box to populate in 1st dropdown.

The user selects the column he wants, and the second dropdown (which I'm trying to make a multi-select dropdown but haven't found a good example that I can get working) to populate with values from a table based on the 1st dropdown selection.

So,

Listbox selected values --> Dropdown1

Dropdown1 selected value becomes parameter for a query to the database to return values for the 1st dropdown.

----
2nd:

There is another set of dropdowns that are populated with the same listbox values. but, when the user selects a value in the 1st dropdown, I want it to disappear in the 2nd set of dropdowns so they can't see it or choose it 2ce.

This is where I thought client-side querying would be better than making calls back to the server for each set of dropdowns.

I currently have client-side scripting populating the selected listbox values into the dropdown boxes but I'm afraid when I do a post-back, they will disappear unless I put them into their own update panel?

Is this confusing or make sense? Also, I'm not using AJAX but as I'm writing this, that might be a good alternative too. I haven't done ASP work in a long time and I'm rusty so when I tried to work with it, I had problems.

If I can get suggestions without AJAX, that would be helpful.
Posted

Server side. Your aim should be to reduce the traffic between the client and the server.
 
Share this answer
 
Comments
Cathryn Crane 21-Jun-11 15:39pm    
So I query the db in the codebehind and is there an easy way to update the dropdown list without having to constantly post back each click?
[no name] 22-Jun-11 11:54am    
AJAX is the only simple solution for that
i also recommend server side coding on this scenario. implementation of Ajax is very very simple in ASP.NET
ajax.net-tutorials.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900