Good afternoon to all,
I am tackling the following task and was hoping someone could shed some more light on the subject. I am trying to create a set or chain of dynamic dropdownlists from a SQL DB. The way it would work is that the next dropdownlist in succession would base its values on the previous dropdownlist.
KEY POINTS: Number of dropdownlists will vary. Actual number needed will be retrieved from DB. For example, one Form may have 2 dropdownlists, while another may have 4. Each successive dropdownlist will populate with values based on the previous.
I am sure that you have seen something to this effect on various eCommerce sites. Where once you choose a size of a piece of clothing, the next dropdownlist will populate with the available colors in that size.
Here is the code I have thus far that simply populates all of the dropdownlists at once. Problem is, not all of the options available in DropDownList 2 may be available for the selected option in DropDownList 1. I would be happy with either a VB
For Each dr In ds.Tables("options").Rows
Dim ddl As New DropDownList
Dim ltlO As New Literal
Dim ltlC As New Literal
ltlO.Text = vbCrLf & "<div class=""styleData_option""><div_ class=""label"">" & dr("styleOpt_title") & ":</div> <span_ class=""textBox"">" & vbCrLf
ltlC.Text = vbCrLf & "</span></div>" & vbCrLf
ddl.ID = dr("styleOpt_title")
ddl.CssClass = "dropDownList"
ddl.AutoPostBack = True
AddHandler ddl.SelectedIndexChanged, AddressOf_ ddl_SelectedIndexChanged
dv = ds.Tables("option_details").DefaultView
dv.RowFilter = "styleOptDtl_styleOptID = " & dr("styleOpt_id")
ddl.DataTextField = "styleOptDtl_title"
ddl.DataValueField = "styleOptDtl_id"
ddl.DataSource = dv
ddl.Items.Insert(0, New_ ListItem(db.text.database2text(dr("styleOpt_prompt "))))
Dolphin Bay, Inc.
-- turning visions into eReality(tm) -- West Palm Beach, FL
Website Design, Internet Strategy, Search Engine Marketing