A
AlecL
Hi there,
I am trying to dynamically add rows of dropdownboxes the number of
which is picked by another dropdown box and although the code is
being processed would not add dropdownboxes to a div.
Here is the code:
Protected Sub ddlMentHowManyChildren_SelectedIndexChanged(ByVal sender
As Object, ByVal e As System.EventArgs)
If ddlMentHaveChildren.SelectedValue <> "" Then
mentChildInfo.Visible = True
ddlMentHowManyChildren.Visible = False
Dim i As Integer
Dim j As Integer = Val(ddlMentHaveChildren.SelectedValue)
For i = 1 To j
Dim ctrlDropDown1 = New
System.Web.UI.WebControls.DropDownList
Dim ctrlDropDown2 = New
System.Web.UI.WebControls.DropDownList
ctrlDropDown1.ID = "ddlMentChildGender" & i
ctrlDropDown2.ID = "ddlMentChildAge" & i
Dim listItem1 As New System.Web.UI.WebControls.ListItem
Dim listItem2 As New System.Web.UI.WebControls.ListItem
Dim IntAge As Integer
For IntAge = 1 To 50
ctrlDropDown2.Items.Add(IntAge.ToString)
Next
Me.mentChildInfo.Controls.Add(ctrlDropDown1)
Me.mentChildInfo.Controls.Add(ctrlDropDown2)
Next
End If
End Sub
In the above code mentChildInfo is the div that is set to runat
="server" and ddlMentHowManyChildren is the ddl which provides the
number of rows.
Any help would be appreciated.
Alec
I am trying to dynamically add rows of dropdownboxes the number of
which is picked by another dropdown box and although the code is
being processed would not add dropdownboxes to a div.
Here is the code:
Protected Sub ddlMentHowManyChildren_SelectedIndexChanged(ByVal sender
As Object, ByVal e As System.EventArgs)
If ddlMentHaveChildren.SelectedValue <> "" Then
mentChildInfo.Visible = True
ddlMentHowManyChildren.Visible = False
Dim i As Integer
Dim j As Integer = Val(ddlMentHaveChildren.SelectedValue)
For i = 1 To j
Dim ctrlDropDown1 = New
System.Web.UI.WebControls.DropDownList
Dim ctrlDropDown2 = New
System.Web.UI.WebControls.DropDownList
ctrlDropDown1.ID = "ddlMentChildGender" & i
ctrlDropDown2.ID = "ddlMentChildAge" & i
Dim listItem1 As New System.Web.UI.WebControls.ListItem
Dim listItem2 As New System.Web.UI.WebControls.ListItem
Dim IntAge As Integer
For IntAge = 1 To 50
ctrlDropDown2.Items.Add(IntAge.ToString)
Next
Me.mentChildInfo.Controls.Add(ctrlDropDown1)
Me.mentChildInfo.Controls.Add(ctrlDropDown2)
Next
End If
End Sub
In the above code mentChildInfo is the div that is set to runat
="server" and ddlMentHowManyChildren is the ddl which provides the
number of rows.
Any help would be appreciated.
Alec