ASP.NET(vb.net) & HTMLTableCellCell - HTMLTableCell : Creates a server-side control that maps to the <td> and <th> HTML elements and allows you manipulate a cell in a table.
ShotDev Focus:
- ASP.NET(vb.net) & HTMLTableCellCell
Tag Control :
- <td or th id="programmaticID"
- align="alignmentofcontentincell"
- bgcolor="bgcolor"
- bordercolor="bordercolor"
- colspan="#ofcolscellspans"
- height="cellheight"
- nowrap="True | False"
- rowspan="#ofrowscellspans"
- valign="vertalignmentofcellcontent"
- width="cellwidth">
- CellContent
- </td or /th>
Example
HTMLTableCell.aspx
- <%@ Page Language="VB" %>
- <script runat="server">
- Sub Button1_OnClick(sender As Object, e As EventArgs)
- Dim numrows As Integer
- Dim numcells As Integer
- Dim i As Integer = 0
- Dim j As Integer = 0
- Dim Row As Integer = 0
- Dim r As HtmlTableRow
- Dim c As HtmlTableCell
- ' Generate rows and cells
- numrows = CInt(Select1.Value)
- numcells = CInt(Select2.Value)
- For j = 0 To numrows-1
- r = new HtmlTableRow()
- If (row Mod 2 <> 0) Then
- r.BgColor = "Gainsboro"
- End If
- row += 1
- For i = 0 To numcells-1
- c = new HtmlTableCell()
- c.Controls.Add(new LiteralControl("row " & j & ", cell " & i))
- r.Cells.Add(c)
- Next i
- Table1.Rows.Add(r)
- Next j
- End Sub
- </script>
- <html>
- <head>
- <title>ShotDev.Com Tutorial</title>
- </head>
- <body>
- <form runat="server">
- Table rows:
- <select id="Select1" runat="server">
- <option Value="1">1</option>
- <option Value="2">2</option>
- <option Value="3">3</option>
- <option Value="4">4</option>
- <option Value="5">5</option>
- </select>
- Table cells:
- <select id="Select2" runat="server">
- <option Value="1">1</option>
- <option Value="2">2</option>
- <option Value="3">3</option>
- <option Value="4">4</option>
- <option Value="5">5</option>
- </select>
- <input id="Button1" type="button" OnServerClick="Button1_OnClick" value="Button" runat="server" />
- <hr />
- <table id="Table1" CellPadding="5" CellSpacing="0" Border="1" runat="server" />
- </form>
- </body>
- </html>
Screenshot