<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<title>HtmlTable Control</title>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim row As Integer = 0
' Generate rows and cells.
Dim numrows As Integer = Convert.ToInt32(Select1.Value)
Dim numcells As Integer = Convert.ToInt32(Select2.Value)
Dim j As Integer
For j = 0 To numrows - 1
Dim r As New HtmlTableRow()
' Set bgcolor on alternating rows.
If row Mod 2 = 1 Then
r.BgColor = "Gainsboro"
End If
row += 1
Dim i As Integer
For i = 0 To numcells - 1
Dim c As New HtmlTableCell()
c.Controls.Add(New LiteralControl("row " & j.ToString() & _
", cell " & i.ToString()))
r.Cells.Add(c)
Next i
Table1.Rows.Add(r)
Next j
End Sub
</script>
</head>
<body>
<h3>HtmlTable Example</h3>
<form id="Form1" runat="server">
<p>
<table id="Table1"
CellPadding=5
CellSpacing=0
Border="1"
BorderColor="black"
runat="server" />
<p>
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>
<br>
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="Submit1" type="submit" value="Generate Table" runat="server">
</form>
</body>
</html>