扫一扫
分享文章到微信

扫一扫
关注官方公众号
至顶头条
| 洪川 | 洪川 | 洪川 | 洪川 | 洪川 | 
| 2,1 | 2,2 | 2,3 | 2,4 | 2,5 | 
| 3,1 | 3,2 | 3,3 | 3,4 | 3,5 | 

 代码没有分离,全部在这里!
代码没有分离,全部在这里!
 <%
<% @ Page Language="C#" %>
@ Page Language="C#" %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 <script runat="server">
<script runat="server">

 protected void Page_Load(object sender, EventArgs e)
    protected void Page_Load(object sender, EventArgs e)
 
     {
{ 
         }
    }
 protected void Button1_Click(object sender, EventArgs e)
    protected void Button1_Click(object sender, EventArgs e)
 
     {
{ int rn = int.Parse(rows.SelectedValue);//得到需要增加的行数
        int rn = int.Parse(rows.SelectedValue);//得到需要增加的行数 int cn = int.Parse(cell.SelectedValue);//得到需要增加的列数
        int cn = int.Parse(cell.SelectedValue);//得到需要增加的列数
 for (int i = 1; i <= rn; i++)//
        for (int i = 1; i <= rn; i++)//
 
         {//进入外部循环,也就是循环增加表行
{//进入外部循环,也就是循环增加表行 TableRow tr = new TableRow();//申明一个表格行
            TableRow tr = new TableRow();//申明一个表格行 for (int j = 1; j <= cn; j++)
            for (int j = 1; j <= cn; j++)
 
             {//进入内部循环,以增加表格列
{//进入内部循环,以增加表格列 TableCell tc = new TableCell();//申明一个表格列
                TableCell tc = new TableCell();//申明一个表格列 if (i == 1)
                if (i == 1)
 
                 {//如果是第一行,就增加下面的字
{//如果是第一行,就增加下面的字 tc.Controls.Add(new LiteralControl("洪川"));
                    tc.Controls.Add(new LiteralControl("洪川")); }
                } else
                else
 
                 {//否则
{//否则 tc.Controls.Add(new LiteralControl(i.ToString() + "," + j.ToString()));//在表格里增加当前是行,列坐标
                    tc.Controls.Add(new LiteralControl(i.ToString() + "," + j.ToString()));//在表格里增加当前是行,列坐标 }
                } tr.Cells.Add(tc);//把列增加到行里面去
                tr.Cells.Add(tc);//把列增加到行里面去 }
            } Table1.Rows.Add(tr);//把行增加到表里去
            Table1.Rows.Add(tr);//把行增加到表里去 }
        } }
    } </script>
</script>
 <html xmlns="http://www.w3.org/1999/xhtml" >
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">
<head runat="server"> <title>无标题页</title>
    <title>无标题页</title> </head>
</head> <body>
<body> <form id="form1" runat="server">
    <form id="form1" runat="server"> <div>
    <div> Table ,这个有点HTML基础的人都知道了,是表格的意思啦,也是布局的一个重要方法,如果是用DW的话,你就会知道他有多重要了!<br />
        Table ,这个有点HTML基础的人都知道了,是表格的意思啦,也是布局的一个重要方法,如果是用DW的话,你就会知道他有多重要了!<br /> 而VS推出的Table服务器控件最大的特色当推他可以动态是控制表格的行列数,下面还是做个演示:<br />
        而VS推出的Table服务器控件最大的特色当推他可以动态是控制表格的行列数,下面还是做个演示:<br /> <br />
        <br /> <strong>
        <strong> 演示一: 动态添加表格行和列,在特定的格里写特定的字,并在当前单元格里面把坐标写出来</strong><br />
        演示一: 动态添加表格行和列,在特定的格里写特定的字,并在当前单元格里面把坐标写出来</strong><br /> <asp:Table ID="Table1" runat="server" BorderColor="Black" BorderStyle="Dashed" BorderWidth="1px" GridLines="Both">
        <asp:Table ID="Table1" runat="server" BorderColor="Black" BorderStyle="Dashed" BorderWidth="1px" GridLines="Both"> </asp:Table>
        </asp:Table> <asp:DropDownList ID="rows" runat="server">
        <asp:DropDownList ID="rows" runat="server"> <asp:ListItem>1</asp:ListItem>
            <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem>
            <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem>
            <asp:ListItem>3</asp:ListItem> <asp:ListItem>4</asp:ListItem>
            <asp:ListItem>4</asp:ListItem> </asp:DropDownList>
        </asp:DropDownList> <asp:DropDownList ID="cell" runat="server">
        <asp:DropDownList ID="cell" runat="server"> <asp:ListItem>1</asp:ListItem>
            <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem>
            <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem>
            <asp:ListItem>3</asp:ListItem> <asp:ListItem>4</asp:ListItem>
            <asp:ListItem>4</asp:ListItem> <asp:ListItem>5</asp:ListItem>
            <asp:ListItem>5</asp:ListItem> </asp:DropDownList>
        </asp:DropDownList> <asp:Button ID="Button1" runat="server" Text="给我建个表格来" OnClick="Button1_Click" /><br />
        <asp:Button ID="Button1" runat="server" Text="给我建个表格来" OnClick="Button1_Click" /><br /> <br />
        <br /> </div>
    </div> </form>
    </form> </body>
</body> </html>
</html>如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。