Add new row in table in code behind problem
<p>I have table on my asp.net page, and I want to insert new rows.I try to add on every click on button new row which contain cell with FileUpload, but it works only for first time. When I click next time, in my code behind table.</p>

<pre><code>    &lt;asp:Panel ID="pnlImages" runat="server" BackColor="Gray" Height="500"&gt;
      &lt;table id="tblImages" runat="server" width="100%"&gt;
        &lt;tr&gt;
          &lt;td&gt;
            &lt;asp:FileUpload ID="FileUpload1" runat="server" /&gt;
          &lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
          &lt;td align="right" width="100"&gt;
            &lt;asp:ImageButton ID="imbAddImage" runat="server" ImageUrl="images/plus.png" 
                  Width="48" Height="48"  OnClick="imbAddImage_Click"/&gt;
         &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
&lt;/asp:Panel&gt;
</code></pre>

<p>This is code on button click</p>

<pre><code>protected void imbAddImage_Click(object sender, ImageClickEventArgs e)
{
    System.Web.UI.HtmlControls.HtmlTable tbl = (System.Web.UI.HtmlControls.HtmlTable)this.FindControl("tblImages");
    System.Web.UI.HtmlControls.HtmlTableRow row = new System.Web.UI.HtmlControls.HtmlTableRow();
    System.Web.UI.HtmlControls.HtmlTableCell cell = new System.Web.UI.HtmlControls.HtmlTableCell();
    FileUpload temp = new FileUpload();
    cell.Controls.Add(temp);
    row.Controls.Add(cell); ;
    int a=tbl.Controls.Count;
    tbl.Controls.AddAt(a-1, row);
}
</code></pre>

<p>But problem is that a is always 2. Can anybody help ?</p>
