In ASP.Net is there anyway to create a form tag (with runat=server) from within the code?
I need to create muliple groups of checkboxes but I don't know how many groups I will need or how many options are in each group.(both of these come from separate database tables)
In asp it was easy. Simplified it was this... and it would create the
the number of checkboxes I needed. And I could do this for each group.
do until RSdob.eof
<INPUT TYPE='checkbox' value=" & RSdbo_("option") & " NAME='OptionList'>" & RSdbo("optionName")
loop
In ASP.Net I tried to do the following
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
Dim item As checkboxlist
Dim ckbArray(5) As checkboxlist
For i = 0 To 5
ckbArray(i) = New checkboxlist
Next
For i = 0 To 5
ckbArray(i).ID = "ckbarray" & i
ckbArray(i).Enabled = True
ckbArray(i).Visible = True
ckbArray(i).Text = "test"
Controls.Add(ckbArray(i))
Next
End Sub
This does not produce checkboxes (it works in
VB.Net and if I change
the checkboxlist to labels it works).
The error messages states that checkboxlist needs to be within a form tag with parameter runat=server.