如何动态创建HTML表? [英] How to dynamically create an HTML Table?
本文介绍了如何动态创建HTML表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何动态创建HTML表或ASP表?我已经尝试过使用下面的代码,但无法正常工作.
How can I dynamically create an HTML table or ASP table? I've tried with code below but it's not working.
Table tb = new Table();
tb.ID="tbl"+TBname;
TableRow rowNew = new TableRow();
tb.Controls.Add(rowNew);
for (int j = 0; j < cols; j++)
{
TableCell cellNew = new TableCell();
Label lblNew = new Label();
rowNew.Controls.Add(cellNew);
}
我想使用循环创建多个HTML表.我该怎么办?
I want to create more then one HTML table using loop. How can I do this?
推荐答案
使用文字控件说
在设计"页面中:
<asp:Literal id="ltrlctrl1" runat=server />
在后面的代码中:
ltrlctrl1.Text = "<table><tr><td>your HTML table contents</td></tr></table>";
请参考:如何:添加文字网络服务器控件到Web窗体页面的缺点/缺点.
Refer to: How to: Add Literal Web Server Controls to a Web Forms Page for its dis/advantages.
这篇关于如何动态创建HTML表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文