动态生成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

上一篇:mysql优化 个人笔记 非礼勿扰 -m04


下一篇:用数组模拟堆、队列