Pra*_*gus 7 c# vb.net web-applications html-table
谁能告诉我如何在我的c#代码中动态创建thead tbody标签?
private void MakeTable()
{
Table tb = new Table();
TableRow tr = new TableRow();
TableCell td = new TableCell();
td.Text="hello world";
tr.Cells.Add(td);
tb.Rows.Add(tr);
}
Run Code Online (Sandbox Code Playgroud)
谢谢
小智 20
这是一个创建THead,TBody和TFooter的示例代码.
您基本上总是可以使用TableRow对象重置TableSection属性.
Table table = new System.Web.UI.WebControls.Table();
TableRow tableRow;
TableCell tableCell;
tableRow = new TableRow();
tableRow.TableSection = TableRowSection.TableHeader;
tableCell = new TableCell();
tableCell.Text = "HEADER";
tableRow.Cells.Add(tableCell);
table.Rows.Add(tableRow);
tableRow = new TableRow();
tableRow.TableSection = TableRowSection.TableBody;
tableCell = new TableCell();
tableCell.Text = "BODY";
tableRow.Cells.Add(tableCell);
table.Rows.Add(tableRow);
tableRow = new TableRow();
tableRow.TableSection = TableRowSection.TableFooter;
tableCell = new TableCell();
tableCell.Text = "FOOTER";
tableRow.Cells.Add(tableCell);
table.Rows.Add(tableRow);
plhTest.Controls.Add(table);
Run Code Online (Sandbox Code Playgroud)
虽然我建议用直接html构建表并附加到页面.
| 归档时间: |
|
| 查看次数: |
12655 次 |
| 最近记录: |