how can selectedvalue of DDL make other DDL visibl
Hi,
i generate 3 dropdownlists. I have to do that with code-behind because i never know in advance how many i need. The amount comes from a database.
Dropdownlist 2 is not visible, the others are visible.
When the selectedvalue of dropdownlist 1 equals "b" then dropdownlist 3 must be visible.
I can do everything except: setting DDL3 visible when selectedvalue of DDL1 equals "b".
Here the code:
Friend dds As New List(Of DropDownList)
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
Dim i As Integer
Dim lit As LiteralControl
Dim z1, z2, z3 As ListItem
For i = 1 To 3
If Not IsPostBack Then
Dim dd As New DropDownList
dd.AutoPostBack = True
dd.ID = i
z1 = New ListItem("a", "a")
z2 = New ListItem("b", "b")
z3 = New ListItem("c", "c")
dd.Items.Add(z1)
dd.Items.Add(z2)
dd.Items.Add(z3)
Session(dd.ID) = dd.ID
If i = 3 Then dd.Visible = False
dds.Add(dd)
Session("dds") = dds
Else
dds = CType(Session("dds"), List(Of DropDownList))
End If
Next
For Each d As DropDownList In dds
form1.Controls.Add(d)
lit = New LiteralControl("<br>")
form1.Controls.Add(lit)
AddHandler d.SelectedIndexChanged, AddressOf dropd
Next
End Sub
Protected Sub dropd(ByVal sender As Object, ByVal e As System.EventArgs)
Dim dd As DropDownList = CType(sender, DropDownList)
If dd.ID = 1 And dd.SelectedValue = "b" Then
[u] 'dd with ID=3 must be visible: how to do that?</u>
End If
End Sub
End Class
Thanks
H.
|