title: On asp:Table Control how do we create a thead?
body: <p>From an <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.tableheaderrow.aspx" rel="nofollow noreferrer">MSDN article</a> on the subject, we can see that we create a <code>TableHeaderRow</code>that contains <code>TableHeaderCell</code>s.</p>
  
  <p>But they add the table header like this:</p>
  
  <pre><code>myTable.Row.AddAt(0, headerRow);
  </code></pre>
  
  <p>which outputs the HTML:</p>
  
  <pre><code>&lt;table id="Table1" ... &gt; 
  &lt;tr&gt; 
      &lt;th scope="column" abbr="Col 1 Head"&gt;Column 1 Header&lt;/th&gt;
      &lt;th scope="column" abbr="Col 2 Head"&gt;Column 2 Header&lt;/th&gt;
      &lt;th scope="column" abbr="Col 3 Head"&gt;Column 3 Header&lt;/th&gt; 
  &lt;/tr&gt;
  &lt;tr&gt; 
      &lt;td&gt;(0,0)&lt;/td&gt;
      &lt;td&gt;(0,1)&lt;/td&gt;
      &lt;td&gt;(0,2)&lt;/td&gt;
  &lt;/tr&gt;
  
  ...
  </code></pre>
  
  <p>and it should have <code>&lt;thead&gt;</code> and <code>&lt;tbody&gt;</code> <em>(so it works seamless with tablesorter)</em> :)</p>
  
  <pre><code>&lt;table id="Table1" ... &gt; 
  &lt;thead&gt;
  &lt;tr&gt; 
      &lt;th scope="column" abbr="Col 1 Head"&gt;Column 1 Header&lt;/th&gt;
      &lt;th scope="column" abbr="Col 2 Head"&gt;Column 2 Header&lt;/th&gt;
      &lt;th scope="column" abbr="Col 3 Head"&gt;Column 3 Header&lt;/th&gt; 
  &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
  &lt;tr&gt; 
      &lt;td&gt;(0,0)&lt;/td&gt;
      &lt;td&gt;(0,1)&lt;/td&gt;
      &lt;td&gt;(0,2)&lt;/td&gt;
  &lt;/tr&gt;
      ...
      &lt;/tbody&gt;
  </code></pre>
  
  <p>the HTML aspx code is </p>
  
  <pre><code>&lt;asp:Table ID="Table1" runat="server" /&gt;
  </code></pre>
  
  <p><strong>How can I output the correct syntax?</strong></p>
  
  <hr>
  
  <p><strong>Just as information</strong>, the <code>GridView</code>control has this built in as we just need to set the Accesbility and use the <code>HeaderRow</code></p>
  
  <pre><code>gv.UseAccessibleHeader = true;
  gv.HeaderRow.TableSection = TableRowSection.TableHeader;
  gv.HeaderRow.CssClass = "myclass";
  </code></pre>
  
  <p>but the question is for the <code>Table</code> control.</p>