/ Published in: C#

create html table dynamically
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Dim i As Integer Dim j As Integer Dim row As HtmlTableRow Dim cell As HtmlTableCell ' Get the number of rows and columns selected by the user. Dim numrows As Integer = CInt(Select1.Value) Dim numcells As Integer = CInt(Select2.Value) ' Iterate through the rows. For j = 0 to numrows - 1 ' Create a new row and add it to the Rows collection. row = New HtmlTableRow() ' Provide a different background color for alternating rows. If (j Mod 2) = 1 Then row.BgColor="Gainsboro" End If ' Iterate through the cells of a row. For i = 0 to numcells - 1 j.ToString() & _ ", cell " & _ i.ToString())) row.Cells.Add(cell) Next i Table1.Rows.Add(row) Next j
Comments
