01.
<%@ Page Language=
"VB"
%>
02.
<script runat=
"server"
>
03.
04.
Sub
Button1_OnClick(sender
As
Object
, e
As
EventArgs)
05.
Dim
numrows
As
Integer
06.
Dim
numcells
As
Integer
07.
Dim
i
As
Integer
= 0
08.
Dim
j
As
Integer
= 0
09.
Dim
Row
As
Integer
= 0
10.
Dim
r
As
HtmlTableRow
11.
Dim
c
As
HtmlTableCell
12.
13.
14.
numrows =
CInt
(Select1.Value)
15.
numcells =
CInt
(Select2.Value)
16.
17.
For
j = 0
To
numrows-1
18.
19.
r = new HtmlTableRow()
20.
21.
If
(row
Mod
2 <> 0)
Then
22.
r.BgColor =
"Gainsboro"
23.
End
If
24.
row += 1
25.
26.
For
i = 0
To
numcells-1
27.
c = new HtmlTableCell()
28.
c.Controls.Add(new LiteralControl(
"row "
& j &
", cell "
& i))
29.
r.Cells.Add(c)
30.
Next
i
31.
32.
Table1.Rows.Add(r)
33.
Next
j
34.
35.
End
Sub
36.
37.
</script>
38.
<html>
39.
<head>
40.
</head>
41.
<body>
42.
<form runat=
"server"
>
43.
Table rows:
44.
<select id=
"Select1"
runat=
"server"
>
45.
<option Value=
"1"
>1</option>
46.
<option Value=
"2"
>2</option>
47.
<option Value=
"3"
>3</option>
48.
<option Value=
"4"
>4</option>
49.
<option Value=
"5"
>5</option>
50.
</select>
51.
Table cells:
52.
<select id=
"Select2"
runat=
"server"
>
53.
<option Value=
"1"
>1</option>
54.
<option Value=
"2"
>2</option>
55.
<option Value=
"3"
>3</option>
56.
<option Value=
"4"
>4</option>
57.
<option Value=
"5"
>5</option>
58.
</select>
59.
<input id=
"Button1"
type=
"button"
OnServerClick=
"Button1_OnClick"
value=
"Button"
runat=
"server"
/>
60.
<hr />
61.
<table id=
"Table1"
CellPadding=
"5"
CellSpacing=
"0"
Border=
"1"
runat=
"server"
/>
62.
</form>
63.
</body>
64.
</html>