Table tblParam = new Table();
//添加N行表格
for (int i = 0; i < n; i++)
{
//创建表格行
TableRow tblRow = new TableRow();
//创建表格列
TableCell tblCell0 = new TableCell();
tblCell0.HorizontalAlign = HorizontalAlign.Right;
tblCell0.Width = Unit.Percentage(30);
Label lbl0 = new Label(); //创建标签
lbl0.Text = "aaa"; //标签标题,你的数据!
tblCell0.Controls.Add(lbl0);
TableCell tblCell1 = new TableCell();
tblCell1.Width = Unit.Percentage(70);
Label lbl = new Label();
lbl.Text = "bbb"; //标签值,你的数据!
tblCell1.Controls.Add(lbl);
tblRow.Cells.Add(tblCell0);
tblRow.Cells.Add(tblCell1);
tblParam.Rows.Add(tblRow);
}
this.Panel1.Controls.Add(tblParam);
注备:
tblParam为Web Control,可使用Web Control所有属性,
tblParam.Width=Unit.Pixel(100);
tblParam.BorderColor = Color.Yellow;
tblParam.BackColor = Color.Green;