title: Adding row to an existing html table from code behind
body: <p>more of newbies :)</p>
  
  <p>I've created HTML table using below html code        </p>
  
  <pre><code> &lt;table runat="server" id="Table1" border="1" class="style1"&gt;
      &lt;tr&gt;
          &lt;td class="style2" colspan="3"&gt;
              Info.&lt;/td&gt;
          &lt;td class="style2" colspan="2"&gt;
              TypeA&lt;/td&gt;
          &lt;td class="style2"&gt;
              TypeB&lt;/td&gt;
          &lt;td class="style2" rowspan="2"&gt;
              TypeC&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="style3"&gt;
              Dept.&lt;/td&gt;
          &lt;td class="style3"&gt;
              Div.&lt;/td&gt;
          &lt;td class="style3"&gt;
              Unit&lt;/td&gt;
          &lt;td class="style3"&gt;
              TypeA.1&lt;/td&gt;
          &lt;td class="style3"&gt;
              TypeA.1&lt;/td&gt;
          &lt;td style="text-align: center"&gt;
              TypeB.1&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I tried to add row for it using </p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {
      TableRow tRow = new TableRow();
      for (int i = 1; i &lt; 8; i++)
      {
          TableCell tb = new TableCell();
          tb.Text = "text";
          tRow.Controls.Add(tb);
      }
      Table1.Rows.Add(tRow);
  }
  </code></pre>
  
  <p>but I got : </p>
  
  <blockquote>
    <p>The best overloaded method match for 'System.Web.UI.HtmlControls.HtmlTableRowCollection.Add(System.Web.UI.HtmlControls.HtmlTableRow)' has some invalid arguments</p>
  </blockquote>
  
  <p>I googled around but with no luck.</p>
  
  <p>I'm doing this to avoid Columns Heading merging action in code behind while I still have to look for how to merge rows heading. This is the last step for completing <a href="https://stackoverflow.com/questions/13670384/asp-net-dynamic-input-display-table-by-section-with-multi-columns-rows-headers">https://stackoverflow.com/questions/13670384/asp-net-dynamic-input-display-table-by-section-with-multi-columns-rows-headers</a> </p>
  
  <p>,.. closer heading view is:</p>
  
  <p><img src="https://i.stack.imgur.com/yF0TU.png" alt="enter image description here"></p>
  
  <p>Rows created will have a forwarding heading cell that should be merged if it's the same with row above. Appreaciate the great assistant from StackOverflow members.</p>