I have the controls in a SQL table and want to read them and make labels and text boxes on a page.
I also need to fill them with data after they are created.
DougP
I also need to fill them with data after they are created.
Code:
Me.lblHeading.Text = Session("formsProLoadForm")
Dim MyTextBox As New TextBox()
Dim MyLabel As New Label
Dim LabelName As String = ""
Dim TxtBoxname As String = ""
Dim connStr As String = ConfigurationManager.ConnectionStrings("FormsConnectionString").ConnectionString
Dim strConn As New SqlConnection(connStr)
Dim Myform As New WebControls.FormView
Myform.ID = "Myform"
Dim objComm As SqlCommand
Dim objReader As SqlDataReader
Dim strSQL As String = "Select FieldName from forms_Main Order by UniqueID"
strConn.Open()
objComm = New SqlCommand(strSQL, strConn)
objReader = objComm.ExecuteReader()
If objReader.HasRows Then
Do While objReader.Read()
MyLabel.ID = "lbl" & objReader.GetString(0)
[highlight #FCE94F] Myform.Page.Controls.Add(MyLabel)[/highlight]
MyTextBox.ID = "txt" & objReader.GetString(0)
Myform.Page.Controls.Add(MyTextBox)
Loop
End If
DougP