Hi Stephanie,
Here's what I would do:
On the first hit of the page, get the first drop down, and hide the second
(using its Visible property).
Set the AutoPostBack property of the first list to True, so the page posts
back when a user selects a different value (or use a "Go" button).
After the page has been posted back, check for the visibility of the second
list. If it is still invisible, this is the first post back, so you need to
retrieve the value of the first list, to populate the second. Then set the
second list's visibility to true.
If the visibility of the second list is true, you know it's the second post
back, so you can use the value of the second list to build another query
statement to retrieve whatever records you need.
Here's things in pseudo code:
If Not page.IsPostback Then
' Bind the first list
' Get dataset or whatever datasource you have
lstOne.DataSource = MyDataSource
lstOne.DataBind()
lstTwo.Visible = False
Else
If lstTwo.Visible = True Then
' Get the value from the second list and do
' whatever you need to do with it.
Else
' First postback, so you need to build the second list here
' Retrieve the value from the selected item from the first
list
' Build a dataset or whatever datasource you need based
' on the value for the first list
lstTwo.DataSource = MyDataSource
lstTwo.DataBind()
' Now make it visible
lstTwo.Visible = True
End If
End If
HtH, and if not, let me know through this list.
Cheers,
Imar
At 09:57 AM 9/27/2002 -0700, you wrote:
>I have, what I hope is a basic "how-to" question, but didn't get any help
>from the "ASPX Beginners" list. 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
>
>---