How to automatically generate labels and textboxes derive from database

Here is the problem:
I have able to generate several labels and textboxes based on a table in the database during runtime. My problem is that I could not get these values from these textboxes whenever a user changes these values and update them.
I am using ASP.NET 2 (VB.NET).
Here is the solution:
‘to generate these textboxes during runtime
   Private Sub GenerateTable()
            Dim row As HtmlTableRow
            Dim cell As HtmlTableCell
            Dim lbl As Label
            Dim txt As TextBox
            For Each dr As DataRow In ds.Tables(0).Rows
                row = New HtmlTableRow()
                cell = New HtmlTableCell()
                lbl = New Label()
                lbl.ID = “lbl” & CStr(dr(0))
                lbl.Text = CStr(dr(1))
                txt = New TextBox()
                txt.ID = “txt” & CStr(dr(0))
                If (Not txt.Text = CStr(dr(2))) Then
                    txt.Text = CStr(dr(2))
                End If
                cell = New HtmlTableCell()
        Catch ex As Exception
            Response.Write(ex.Message & ” ” & ex.StackTrace)
        End Try
    End Sub
Some further information or references that I used:
This entry was posted in VB.NET 2 AND ASP.NET 2. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s