Visual Studio .NET - dynamic dropdownlist control |
| toma hawk posted at 24-Aug-04 12:34 |
 | Hi
in my code for aspx i create a dropdown list dynamically and add it to a place holder control ,but upon postback i am unable to find the control or find the selected value in the dropbox so that i can create another dropbox with some other values.Here is the code
how do i solve this issue ? i tried adding the control again after postback
Please help
---------------------------------------------------------
Dim dd1 As DropDownList = New DropDownList
Dim dd2 As DropDownList = New DropDownList
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Me.IsPostBack = True Then
' PlaceHolder1.Controls.Add(dd1)
' Dim dd2 As DropDownList = CType(Me.Placeholder1.FindControl("dd1"), DropDownList)
If dd1.SelectedIndex = 2 Then
dd2.Items.Add("None")
dd2.Items.Add("B1")
dd2.Items.Add("B2")
PlaceHolder1.Controls.Add(dd2)
End If
Else
dd1.Items.Add("None")
dd1.Items.Add("A1")
dd1.Items.Add("A2")
dd1.AutoPostBack = True
dd1.EnableViewState = False
PlaceHolder1.Controls.Add(dd1)
End If
End Sub
----------------------------------------------------------------------- |