Table Code
Table.aspx
1 2 3 4 5 6 | <%@ Control Language="vb" AutoEventWireup="false" Codebehind="table.aspx.vb" Inherits="DamianM.Table1" %> <%@ Register TagPrefix="cc1" Namespace="DamianM" Assembly="DamianM" %> <center> <Table id="Table1" runat="server"> </Table> </center> |
Table.aspx.vb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | Public Class Table1 Inherits System.Web.UI.UserControl Protected WithEvents Table1 As System.Web.UI.HtmlControls.HtmlTable Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'declare holders for the rows and cells you are going to create Dim r As System.Web.UI.HtmlControls.HtmlTableRow Dim c As System.Web.UI.HtmlControls.HtmlTableCell 'all the tables attribute are available to be set 'through the tables object Table1.Border = 1 Table1.Width = "50%" 'creare a new row r = New System.Web.UI.HtmlControls.HtmlTableRow() 'create a new cell c = New System.Web.UI.HtmlControls.HtmlTableCell() 'all the cells attribute are available to be set 'through the tables object c.ColSpan = 2 c.Align = "center" c.BgColor = "silver" c.InnerText = "Server Created Table" 'add the new cell to the row r.Cells.Add(c) 'add the new row to the table Table1.Rows.Add(r) 'a loop to create a sample table Dim i As Integer For i = 0 To 10 r = New System.Web.UI.HtmlControls.HtmlTableRow() 'all the rows attribute are available to be set 'through the tables object r.BgColor = &H999999 + (i * 1024) ' set the color to something c = New System.Web.UI.HtmlControls.HtmlTableCell() c.InnerText = i.ToString r.Cells.Add(c) c = New System.Web.UI.HtmlControls.HtmlTableCell() c.InnerText = "this is row " + i.ToString r.Cells.Add(c) Table1.Rows.Add(r) Next End Sub Private Sub InitializeComponent() End Sub End Class |



















