Table tb = new Table();
tb.ID = "myTable";
tb.Height = Unit.Pixel(200);
tb.Width = Unit.Pixel(200);
tb.BorderWidth = Unit.Pixel(3);
tb.CellPadding = 2;
tb.CellSpacing = 2;
for (int i = 0; i < 3; i++)
{
TableRow tr = new TableRow();
tr.ID = "row" + i.ToString();
for (int j = 0; j < 2; j++)
{
TableCell tc = new TableCell();
tc.ID = "cell" + i.ToString() + j.ToString();
tc.Text = "cell" + i.ToString() + j.ToString();
tr.Cells.Add(tc);
}
tb.Rows.Add(tr);
}
form1.Controls.Add(tb);
reference:
http://www.codeproject.com/KB/aspnet/DynamicServerControls.aspx
No comments:
Post a Comment