Return to Snippet

Revision: 33485
at October 9, 2010 03:30 by hairajeshk


Initial Code
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 
           
               ' Create a new cell and add it to the Cells collection.
               cell = New HtmlTableCell()
               cell.Controls.Add(new LiteralControl("row " & _ 
                                                 j.ToString() & _ 
                                                 ", cell " & _
                                                 i.ToString()))
               row.Cells.Add(cell)
            
            Next i

            Table1.Rows.Add(row)
         
         Next j

Initial URL

                                

Initial Description
create html table dynamically

Initial Title
create html table dynamically

Initial Tags
table, html

Initial Language
C#