简单教程
提交运行
代码编辑器:
<script runat="server"> Sub Page_Load(sender As Object, e As EventArgs) dim rows,cells,j,i rows=3 cells=2 For j=0 To rows-1 dim r As New TableRow() For i=0 To cells-1 dim c As New TableCell() c.Controls.Add(New LiteralControl("row " & j & ", cell " & i)) r.Cells.Add(c) Next Table1.Rows.Add(r) Next End Sub </script> <!DOCTYPE html> <meta charset="utf-8" /> <form runat="server"> <asp:Table id="Table1" BorderWidth="1" GridLines="Both" runat="server" /> </form>
运行结果: