动态生成web表-asp.net table

1. 页面上定义一个server 的table

<table style="width: 100%" id="tbContent" runat="server">
</table>

 

2. 后台

HtmlTableRow rowQy = new HtmlTableRow();
HtmlTableCell cellHeadQty = new HtmlTableCell();
cellHeadQty.Width = "60";
cellHeadQty.Align = "left";
cellHeadQty.InnerText = "Total Demand Qty";
rowQy.Cells.Add(cellHeadQty);
 
for (int i = 1; i < 13; i++)
{
    HtmlTableCell cell = new HtmlTableCell();
    TextBox tb = new TextBox();
    tb.ID = "tbQty" + i.ToString();
    tb.Width = 50;
    cell.Align = "center";
    cell.Controls.Add(tb);
    rowQy.Cells.Add(cell);
}
tbContent.Rows.Add(rowQy);

 

 

疯吻IT

posted @ 2015-02-07 10:44  疯吻IT  阅读(783)  评论(0编辑  收藏  举报