T
Terry Olsen
I want to have a series of DropDownLists appear. On PageLoad, the first
list is created. When I make a choice, a 2nd list is created, data
loaded depending on the choice from the first list, and so on...
However, when the choice is made on the 2nd list, it goes away and only
the 1st list remains (because it's being created on PageLoad).
Here's the code. Hope someone can help:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
AddDDL(GetColumnNames, "ddlCol")
End If
End Sub
Private Sub AddDDL(ByVal data As ArrayList, ByVal name As String)
Dim MyDDL As New DropDownList
With MyDDL
.DataSource = data
.DataBind()
.ID = name
.AutoPostBack = True
End With
PlaceHolder1.Controls.Add(MyDDL)
AddHandler MyDDL.SelectedIndexChanged, AddressOf
DDL_SelectedIndexChanged
End Sub
Private Sub DDL_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Dim MyDDL As DropDownList = CType(sender, DropDownList)
If InStr(MyDDL.ID, "Col") Then
Dim MyAL As New ArrayList
With MyAL
.Add("=") : .Add("<>") : .Add(">") : .Add("<")
End With
AddDDL(MyAL, "ddlExp")
AddDDL(GetDistinctFromColumn(MyDDL.SelectedItem.ToString), "ddlDat")
ElseIf InStr(MyDDL.ID, "Exp") Then
'Don't do anything, just making a choice.
ElseIf InStr(MyDDL.ID, "Dat") Then
'Code here to add another column list
End If
End Sub
list is created. When I make a choice, a 2nd list is created, data
loaded depending on the choice from the first list, and so on...
However, when the choice is made on the 2nd list, it goes away and only
the 1st list remains (because it's being created on PageLoad).
Here's the code. Hope someone can help:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
AddDDL(GetColumnNames, "ddlCol")
End If
End Sub
Private Sub AddDDL(ByVal data As ArrayList, ByVal name As String)
Dim MyDDL As New DropDownList
With MyDDL
.DataSource = data
.DataBind()
.ID = name
.AutoPostBack = True
End With
PlaceHolder1.Controls.Add(MyDDL)
AddHandler MyDDL.SelectedIndexChanged, AddressOf
DDL_SelectedIndexChanged
End Sub
Private Sub DDL_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Dim MyDDL As DropDownList = CType(sender, DropDownList)
If InStr(MyDDL.ID, "Col") Then
Dim MyAL As New ArrayList
With MyAL
.Add("=") : .Add("<>") : .Add(">") : .Add("<")
End With
AddDDL(MyAL, "ddlExp")
AddDDL(GetDistinctFromColumn(MyDDL.SelectedItem.ToString), "ddlDat")
ElseIf InStr(MyDDL.ID, "Exp") Then
'Don't do anything, just making a choice.
ElseIf InStr(MyDDL.ID, "Dat") Then
'Code here to add another column list
End If
End Sub