ASP.NET AddTable

 protected void BtnSace_Click( object sender, EventArgs e )
    {
        int cellCount = int.Parse( this.TextBox1.Text );
        int rowCount = int.Parse( this.TextBox2.Text );
        string data = this.TextBox3.Text;
        for ( int i = 0; i < rowCount; i++ )
        {
            TableRow row = new TableRow( );
            Table1.Rows.Add( row );
            string input = this.TextBox1.Text;
            for ( int j = 0; j < cellCount; j++ )
            {
                TableCell cell = new TableCell( );// + j + input + i  new LiteralControl( +i)
                cell.Controls.Add(new LiteralControl(input));
                row.Cells.Add( cell );
                cell.Width = Unit.Pixel( 40 );
                cell.Text = data;
            }
        }

    }

posted @ 2012-07-01 18:33  blog_yuan  阅读(336)  评论(0编辑  收藏  举报