您的位置:首页 > 其它

创建服务器控件(表格) 

2008-05-19 17:51 225 查看
protected void Page_Load(object sender, EventArgs e)
{
HtmlTable tb1 = new HtmlTable();
HtmlTableRow row;
HtmlTableCell cell;

tb1.Border = 1;
tb1.CellPadding = 3;
tb1.CellSpacing = 3;
tb1.BorderColor = "BLUE";
//创建行
for (int i = 1; i <= 5; i++)
{
row = new HtmlTableRow();
row.BgColor = (i % 2 == 0 ? "red" : "lightcyan");
//创建数据单元
for (int j = 1; j <= 4; j++)
{
cell = new HtmlTableCell();
cell.InnerHtml = "Row:" + i.ToString();
row.Cells.Add(cell);
}
tb1.Rows.Add(row);
}
//把表添加到页面的Controls集合中
Page.Controls.Add(tb1);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: