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()
        Try
            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))
                cell.Controls.Add(lbl)
                row.Cells.Add(cell)
                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()
                cell.Controls.Add(txt)
                row.Cells.Add(cell)
                Me.tblSetParameters.Rows.Add(row)
            Next
        Catch ex As Exception
            Response.Write(ex.Message & ” ” & ex.StackTrace)
        End Try
    End Sub
Some further information or references that I used:
Advertisements
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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s