Vote count:
0
I'm creating a table control dynamically and adding all of the rows and columns. Here's what I'm doing (roughly):
Table t = new Table();
TableRow tr = new TableRow();
tr.TableSection = TableRowSection.TableHeader;
t.Rows.Add(tr);
foreach (DataColumn col in dataTable.Columns)
{
TableHeaderCell c = new TableHeaderCell();
tr.Cells.Add(c);
c.Text = col.ColumnName;
}
foreach (DataRow r in dataTable.Rows)
{
tr = new TableRow();
tr.TableSection = TableRowSection.TableBody;
t.Rows.Add(tr);
foreach (DataColumn col in dataTable.Columns)
{
TableCell c = new TableCell();
tr.Cells.Add(c);
c.Text = r[col].ToString();
}
}
TableRow footerRow = new TableRow();
footerRow.TableSection = TableRowSection.TableFooter;
t.Rows.Add(footerRow);
foreach (DataColumn col in dataTable.Columns)
{
TableHeaderCell c = new TableHeaderCell();
footerRow.Cells.Add(c);
c.Text = "Test";
}
Everything was working great until I added the TableFooter row and now I'm getting this error when the table control is added to the page.
The table must contain row sections in order of header, body, then footer
I thought that was the order that I was adding the rows in? Header, then body, then footer
asked 1 min ago
Dynamic WebControls.Table
Aucun commentaire:
Enregistrer un commentaire