Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Building dynamic dropdownlists


Message #1 by "Patterson, Stephanie L" <stephanie.l.patterson@i...> on Wed, 25 Sep 2002 08:35:02 -0700
I have, what I hope is a basic "how-to" question. Please bear with me...
For my examples, I'm going to use the SQL database "pubs" which has a table
"titles".

In SQL, if I want to select all the "titles" records where the the pub_id 
"0877", I do the following: SELECT * FROM titles WHERE pub_id = "0877".
Then, if I want to select only the title of the books where the type 
"mod_cook", I do the following:  SELECT title FROM titles WHERE type 
'mod_cook.  OK.  That's pretty straight forward, but it is in SQL.

In my ASP.NET app, I have dropdownlists that will eventually be the part of
a condition of my SQL select for a chart.  For example, using the titles
analogy, I'd have a dropdownlist (ddlPubId) that 'select pub_id from titles
group by pub_id' is the contents of the dropdownlist and another one
(ddlType)that 'select type from titles group by type where pub_id 
ddlPubId.SelectedItem', etc. (basically each dropdownlist only shows records
from titles that are available once the previous DDLs have been chosen -
each are filtered).  Then in my vb code-behind, I'd have a select query that
would something similiar to: select * from titles where (pub_id 
ddlPubId.SelectedItem) AND (type = ddlType).  The results of this select are
then stored in a datatable which is the source for my chart.  

What is the best method to build the dropdownlists based on 'filtering' each
list based on the previously selected list(s)?  

I'm using VB.NET if that matters.

In advance, THANKS!
Stephanie

  Return to Index