I am trying to dynamically build an ASP Table in the code behind. I have a regular application where this is needed. I did this years ago and can't remember how to do it. So, I created a simple page in order to test it and I just can't get it to show up. Any ideas what I'm doing wrong?
Thanks,
Thanks,
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim tr As New TableRow
Dim td As New TableCell
Try
Dim i As Integer = 1
For x As Integer = 0 To 20 - 1
If i > 5 Then
Table1.Rows.Add(tr)
i = 1
tr = New TableRow
End If
td.Text = x & " Cell(s)"
tr.Cells.Add(td)
i += 1
Next
Catch ex As Exception
Dim strErr As String = "Page_Load() - " & ex.Message
End Try
End Sub
HTML Code:
<body>
<form id="form1" runat="server">
<div>
<asp:Table ID="Table1" runat="server"></asp:Table>
</div>
</form>
</body>