table1.aspx

来自「《精通ASP.NET网络编程》附带实例」· ASPX 代码 · 共 84 行

ASPX
84
字号
<html>
<head>

    <script language="VB" runat="server">

       Sub Page_Load(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
        
            ' 产生行和列
            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("行 " & j & ", 列 " & i))
                    r.Cells.Add(c)
                Next i
                
                Table1.Rows.Add(r)
            Next j
       End Sub

    </script>

</head>
<body>

    <form runat=server>
    <font face="Verdana" size="-1">
        <p>

        <table id="Table1" CellPadding=5 CellSpacing=0 Border="1" runat="server" />
        
        <p>
        行:
        <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>
       列:
        <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 type="submit" value="产生表" runat="server">

    </font>
    </form>

</body>
</html>







⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?