Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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??

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
525 views
Welcome To Ask or Share your Answers For Others

1 Answer

Here is how (below). All classes used are in System.Web.UI.WebControls.

        TableRow headerRow = new TableHeaderRow();
        TableRow row2 = new TableRow();
        TableRow row3 = new TableFooterRow();
        Table table = new Table();

        var cell1 = new TableCell();
        headerRow.TableSection = TableRowSection.TableHeader;
        cell1.Text = "Header";
        headerRow.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(headerRow);
        table.Rows.Add(row2);
        table.Rows.Add(row3);
        this.Controls.Add(table);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...