title: can't render thead or tfoot tags in asp.net
body: <p>According to <a href="http://msdn.microsoft.com/en-us/library/vstudio/ms227996(v=vs.100).aspx" rel="nofollow noreferrer">this post</a> </p>
  
  <blockquote>
    <p>When you create a Table object, include the TableHeaderRow and
    TableHeaderCell controls. The default values of the TableHeaderRow and
    TableFooterRow controls <strong>cause the control to render thead, tbody, and
    tfoot elements</strong></p>
  </blockquote>
  
  <p>I have been trying to get the <code>thead</code> and <code>tfoot</code> tags to render without success. </p>
  
  <p>I am using the classes mentioned in that link I posted and I only get <code>tbody</code> with a bunch of nested <code>tr</code> tags. I am using VS2012 pro and .net 4.5.</p>
  
  <p>What am I doing wrong? </p>
  
  <pre><code>public void BuildHTMLTable(DataTable dt)
  {
      StringWriter sw = new StringWriter();
      HtmlTextWriter w = new HtmlTextWriter(sw);
  
      Table tbl = new Table();
  
      // create table header
      TableHeaderRow thr = new TableHeaderRow();
      foreach (DataColumn col in dt.Columns)
      {
          TableHeaderCell thc = new TableHeaderCell();
          thc.Text = col.Caption;
          thr.Cells.Add(thc);
      }
      tbl.Rows.AddAt(0, thr);
  
      // write out each data row
      foreach (DataRow row in dt.Rows)
      {
          TableRow tr = new TableRow();
          foreach (var value in row.ItemArray)
          {
              TableCell td = new TableCell();
              td.Text = value.ToString();
              tr.Controls.Add(td);
          }
          tbl.Rows.Add(tr);
      }
  
      // Create table footer
      TableFooterRow tfr = new TableFooterRow();
      foreach (DataColumn col in dt.Columns)
      {
          TableCell th = new TableCell();
          th.Text = col.Caption;
          tfr.Cells.Add(th);
      }
      tbl.Rows.Add(tfr);
  
      // Renter the table to html writer
      tbl.RenderControl(w);
      // copy html writer to a string variable
      tableString = sw.ToString();
  }
  </code></pre>
  
  <p><strong>rendered HTML below</strong></p>
  
  <p><img src="https://i.stack.imgur.com/3R26i.png" alt="rendered html"></p>