zoukankan      html  css  js  c++  java
  • 使用HtmlControl动态创建一个表格

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
     
    public partial class Chapter04_CreateTableByCode : System.Web.UI.Page
    {
        // 使用Html服务器控件创建一个5行4列的表格
        protected void Page_Load(object sender, EventArgs e)
        {
            HtmlTable table = new HtmlTable();
            table.Border = 1;
            table.CellSpacing = 3;
            table.CellPadding = 3;
            table.BorderColor = "red";
     
            HtmlTableRow row;
            HtmlTableCell cell;
            for (int i = 1; i <= 5; i++)
            {
                row = new HtmlTableRow();
                row.BgColor = i % 2 == 0 ? "lightyellow" : "lightcyan";
                for (int j = 1; j <= 4; j++)
                {
                    cell = new HtmlTableCell();
                    cell.InnerHtml = "Row : " + i.ToString() + "<br />Cell: " + j.ToString();
                    row.Cells.Add(cell);
                }
                table.Rows.Add(row);
            }
            this.Controls.Add(table);
        }
    }

    效果:

    image

  • 相关阅读:
    日志
    mysql锁
    慢查询
    auto_increment
    脚本
    服务器元数据
    复制表及表数据
    临时表
    (一)校园信息通微信小程序从前端到后台整和笔记
    OpenCart框架运行流程介绍opencart资料链接
  • 原文地址:https://www.cnblogs.com/SkySoot/p/2579576.html
Copyright © 2011-2022 走看看