C#创建THEAD和TBODY [英] c# create thead and tbody

查看:457
本文介绍了C#创建THEAD和TBODY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我如何在我的C#代码动态创建THEAD TBODY标签?

Can anyone tell me how to dynamically create thead tbody tags in my c# code?

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);
}



感谢

Thanks

推荐答案

下面创建一个THEAD,TBODY和TFooter一个示例代码。

Here a sample code that creates a THead, TBody and TFooter.

您基本上可以一直使用的TableRow对象只是重置TableSection 。酒店

You can basically always use the TableRow object just reset the TableSection property.

    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);



虽然我会建议建立表直接HTML和追加到网页。

Although I would suggest building the table in direct html and appending to page.

这篇关于C#创建THEAD和TBODY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆