Raise Event for Dynamically Added DropDownList
Good afternoon to all,
Since I seemed to have stumped the experts on here as to how to go about creating a "chain" of dropdownlists, I was hoping someone could help me with a smaller issue. How would I go about raising an event for a particular dropdownlist when multiple dropdownlists are being added to a webform dynamically. Please see my code below.
For Each dr In ds.Tables("options").Rows
Dim ddl As New DropDownList
ddl.ID = dr("styleOpt_title")
ddl.AutoPostBack = True
styleData_optionBasket.Controls.Add(ddl)
AddHandler ddl.SelectedIndexChanged, AddressOf ddl_SelectedIndexChanged
ddl.Items.Insert(0, New ListItem("Please select..."))
Next
As I could potentially be adding upward of 4 DropDownLists to a form, how could I raise an event for the, let's say, 3rd DropDown. Right now, when I call the ddl_selectedIndexChanged event, the values from all of the dropdownlists are being captured.
Thank you and I hope someone can lend some much needed assistance.
Regards.
|