title: How do I add table header dynamically in c#?
body: <p>I have successfully created generating new records into table rows but want to add table header, so how to do that?</p>
  
  <pre><code>private void GenerateTable(int rowsCount)
          {
              Table table = new Table();
              table.ID = "Table1";
              Page.Form.Controls.Add(table);
              const int colsCount = 3;
              for (int i = 0; i &lt; rowsCount; i++)
              {
                  TableRow row = new TableRow();
                  for (int j = 0; j &lt; colsCount; j++)
                  {                    
                      TableCell cell = new TableCell();
                      TextBox tb = new TextBox();
                      tb.ID = "TextBoxRow_" + i + "Col_" + j;
                      cell.Controls.Add(tb);
                      row.Cells.Add(cell);
                  }
                  table.Rows.Add(row);
              }
              SetPreviousData(rowsCount, colsCount);
              rowsCount++;
              ViewState["RowsCount"] = rowsCount;
          }
  </code></pre>