[ACCEPTED]-c# create thead and tbody-html-table
Accepted answer
Here a sample code that creates a THead, TBody 5 and TFooter.
You can basically always use 4 the TableRow object just reset the TableSection 3 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);
Although I would suggest building 2 the table in direct html and appending to 1 page.
TableRow is basically tbody
.
To make a thead
section, use 3 the TableHeaderRow class instead of a TableRow class.
(There 2 is also, btw, TableFooterRow if you want to implement 1 tfoot
.
var row = new TableHeaderRow() { TableSection = TableRowSection.TableHeader };
table.Rows.Add(row);
should do the trick
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.