zoukankan      html  css  js  c++  java
  • Asp.net Form 动态产生表格核心前后台代码

    前端参考代码:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <link href="htzd.css" rel="stylesheet" />
        <title></title>
    </head>
    <body>
        <asp:Table ID="Table1" runat="server"></asp:Table>
        <br />
        <hr />
        <form id="form1" runat="server">
        <div>    
            Row Num:<asp:TextBox ID="RowNum" style="color:red" runat="server" Text="0"></asp:TextBox>
            <br />
            Col Num:<asp:TextBox ID="ColNum" runat="server" Text="0" ForeColor="Red"></asp:TextBox>
            <br />
            <br />
            <asp:Button ID="btnProTable" runat="server" Text="产生表格" />    
        </div>
        </form>
    </body>
    </html>

    参考代码:

      protected void Page_Load(object sender, EventArgs e)
            {
                if (this.IsPostBack == true)
                {
                    int row = int.Parse(Request.Form["RowNum"]);
                    int col = int.Parse(Request.Form["ColNum"]);
                    for (int i = 0; i < row; i++)
                    {
                        TableRow tr = new TableRow();
                        for (int j = 0; j < col; j++)
                        {
                            TableCell td = new TableCell();
                            tr.Cells.Add(td);
                            td.Text =((i+1)*(j+1)).ToString();
                        }
                        Table1.Rows.Add(tr);
                    }
                }
            }

     htzd.css参考文件:

    table{
        width:400px;
        box-shadow:5px 5px 5px grey;    
    }
    td{
        box-shadow:3px 3px 3px grey;
        padding-left:15px;    
    }
  • 相关阅读:
    2月8日
    2月7日
    2月6日
    2月5日
    事务
    synchronized关键字详解(二)
    synchronized关键字详解(一)
    java.sql.SQLException: Access denied for user 'somebody'@'localhost' (using password: YES)
    wex5 教程 之 图文讲解 wex5集成HTML5 视频播放器
    wex5 实战 加密与解密系列(1) DES算法引入与调用
  • 原文地址:https://www.cnblogs.com/exesoft/p/13245913.html
Copyright © 2011-2022 走看看