protected void Table_Create()
{
//------------------------------------------------------------------
TableRow tr; //定义的表格的行
TableCell tc; //定义表格的列
int TrNum = 15; //行数
int TcNum = 5;//列数
Literal Lie1;
for (int n = 0; n < TrNum;n++ )
{
tr = new TableRow();
for (int v = 0; v < TcNum;)
{
tc = new TableCell();
Lie1 = new Literal();
tc.Width = Unit.Pixel(50);
Lie1.Text = "行" + n + "列" + v;
tc.Controls.Add(Lie1);
//tc.Controls.Add(new LiteralControl("行" + n + "列" + v));
tc.HorizontalAlign = HorizontalAlign.Center;
if(v%2==0)
{
tc.BackColor = Color.HotPink;
}
else
{
tc.BackColor = Color.Green;
}
tr.Cells.Add(tc);
tc.Attributes.Add("onclick", "alert('第" + n + "行" + ",第" + v + "列');");
v++;
}
Table2.Rows.Add(tr);
if(n%2==0)
{
tr.Attributes.Add("style", "page-break-after:always;BackColor:Back;");
}
}
Table2.Width = Unit.Pixel(560);
Table2.BorderWidth = Unit.Pixel(1);
Table2.BorderStyle = BorderStyle.Ridge;
//Table2.Attributes.Add("onclick","return confirm('是否继续测试?');");
}