下文所有内容转自开源中国:http://www.oschina.net/question/565065_86453#tags_nav
=============================================================================
ASP.NET中服务器控件Table动态生成表格
1 Table tb = new Table(); 2 3 int row = 3; // 行数 4 int col = 4; // 列数 5 for(int i=0;i<row;i++) 6 7 { 8 TableRow tr = new TableRow(); 9 tb.Rows.Add(tr); 10 11 for(int j=0;j<col;j++) 12 13 { 14 TableCell td = new TableCell(); 15 tr.Cells.Add(td); 16 td.Text = i.ToString(); 17 } 18 }