HTMLTABLE,HtmlTableRow,HtmlTableCell - 创造THEAD,TBODY TFOOT和 [英] HtmlTable, HtmlTableRow, HtmlTableCell - creating thead, tbody and tfoot
问题描述
我用C#ASP .Net和HTMLTABLE,HtmlTableRow,HtmlTableCell创建一个表的工作。
例如...我需要有一定的细胞由被包裹<&TFOOT GT;和< / TFOOT>
我试着用HtmlGenericControl做包裹这些细胞与标签TFOOT到HTMLTABLE但没有工作。
我知道HtmlTableCell可以在构造函数日为THEAD和TD为TBODY。
,但我需要他们用实际的THEAD和TBODY包裹。
任何建议??
< DIV CLASS =h2_lin>解决方案
下面是如何(下图)。 。使用的所有类都在System.Web.UI.HtmlControls
的TableRow行=新TableHeaderRow();
的TableRow ROW2 =新的TableRow();
的TableRow ROW3 =新TableFooterRow();
表表=新表();
变种CELL1 =新的TableCell();
row.TableSection = TableRowSection.TableHeader;
cell1.Text =头;
row.Cells.Add(CELL1);
变种CELL 2 =新的TableCell();
cell2.Text =内容;
row2.Cells.Add(CELL 2);
变种CELL3 =新的TableCell();
cell3.Text =页脚;
row3.Cells.Add(CELL3);
row3.TableSection = TableRowSection.TableFooter;
table.Rows.Add(行);
table.Rows.Add(ROW2);
table.Rows.Add(ROW3);
this.Controls.Add(表);
I'm working with c# ASP .Net, HtmlTable, HtmlTableRow, HtmlTableCell to create a table.
for example... i need to have some cells to be wrapped by <tfoot> and </tfoot>
i tried to do it with HtmlGenericControl to wrap these cells with the tag "tfoot" to the HtmlTable but it didn't work.
i know that HtmlTableCell can have in the constructor "th" for "thead" and "td" for tbody. but i need them to be wrapped with the actual "thead" and "tbody".
Any Suggestions??
Here is how (below). All classes used are in System.Web.UI.HtmlControls.
TableRow row = new TableHeaderRow();
TableRow row2 = new TableRow();
TableRow row3 = new TableFooterRow();
Table table = new Table();
var cell1 = new TableCell();
row.TableSection = TableRowSection.TableHeader;
cell1.Text = "Header";
row.Cells.Add(cell1);
var cell2 = new TableCell();
cell2.Text = "Contents";
row2.Cells.Add(cell2);
var cell3 = new TableCell();
cell3.Text = "Footer";
row3.Cells.Add(cell3);
row3.TableSection = TableRowSection.TableFooter;
table.Rows.Add(row);
table.Rows.Add(row2);
table.Rows.Add(row3);
this.Controls.Add(table);
这篇关于HTMLTABLE,HtmlTableRow,HtmlTableCell - 创造THEAD,TBODY TFOOT和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!