• ASP.NET动态增加或减少TABLE列和行 控件实例


    HTML 代码!
        <asp:Table id="Table1" runat="server" BorderColor ="DeepSkyBlue" BorderStyle="Outset" BorderWidth="1px" CaptionAlign="Top"/>


    //CS代码!

    public partial class vs2005sample_table : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Dtable();    
        }
        //动态生成表单
        protected void Dtable()
        {
            int numrows = 3;
            int numcells = 2;
            for (int j = 0; j < numrows; j++)
            {
                TableRow r = new TableRow();
                for (int i = 0; i < numcells; i++)
                {
                    TableCell c = new TableCell();

    // 作用与下一句作用一个,为单元格添加内容           

    //    c.Text = string.Format("第{0}行,第{1}列", j + 1, i + 1);

                    c.Controls.Add(new LiteralControl("row   " + j.ToString() + ",   cell   " + i.ToString()));
                    r.Cells.Add(c);
                }
                Table1.Rows.Add(r);
            }
        }}


    本文来自: IT知道网(http://www.itwis.com) 详细出处参考:http://www.itwis.com/html/net/aspnet/20080326/1149.html

  • 相关阅读:
    王者荣耀_KEY
    月亮之眼_KEY
    编号中的数学_KEY
    BZOJ1854_游戏_KEY
    BZOJ1059_矩阵游戏_KEY
    最小覆盖_KEY
    Dijkstra堆优化学习
    LuoguP1196_银河英雄传说_KEY
    BZOJ1207_打鼹鼠_KEY
    Codevs1380没有上司的舞会_KEY
  • 原文地址:https://www.cnblogs.com/star250/p/1434843.html
Copyright © 2020-2023  润新知