title: Dynamically adding row asp.net (on button click) - using dynamic HTML - row not shown
body: <p>I have at table and a button. The first time the page loads, this method is called and it works perfectly. When I press the button ' New Slot' and this method is called, I am able to see during debugging that row.count increases for this table, yet in the browser, a new is not rendered (so it isn't the case that maybe one row pops on another). I am using an update panel in my UI, but with or without it I have the same effects. I also tried re-adding the table everytime in this method, but only 1 row is SHOWN/RENDERED, yet if I type something in the row, and then add another one, the stuff in the first row is lost, may be the row is being added and the previous one deleted? Maybe I have to use the viewstate? Can someone guide me to the right solution please?</p>
  
  <pre><code>private void AddSlot()
          {
              DropDownList ddlProfiles = new DropDownList();
              ddlProfiles.DataSource = DLProfiles.Instance.GetAllProfilesByGid(Int32.Parse(Session["gid"].ToString()));
              ddlProfiles.DataTextField = "pName";
              ddlProfiles.DataBind();
  
              TableRow row = new TableRow();
  
              TableCell cellProfile = new TableCell();
              cellProfile.Controls.Add(ddlProfiles);
  
              TableCell cellStart = new TableCell();
              TextBox startTime = new TextBox();
              cellStart.Controls.Add(startTime);
  
              TableCell cellEnd = new TableCell();
              TextBox endTime = new TextBox();
              cellEnd.Controls.Add(endTime);
  
              row.Cells.Add(cellProfile);
              row.Cells.Add(cellStart);
              row.Cells.Add(cellEnd);
  
              scheduleTable.Rows.Add(row);
  
          }
  
  &lt;asp:UpdatePanel ID="pnlSchedTable" runat="server"&gt;
                  &lt;ContentTemplate&gt;
          &lt;div id="divCurrentSchedule" runat="server"&gt;
              &lt;h3 id="scheduleTitle" runat="server"&gt;
              &lt;/h3&gt;
  
                      &lt;asp:Table ID="scheduleTable" runat="server"&gt;
                          &lt;asp:TableHeaderRow ID="rowHeaders" runat="server"&gt;
                              &lt;asp:TableHeaderCell Text="Profile Name" /&gt;
                              &lt;asp:TableHeaderCell Text="Start time" /&gt;
                              &lt;asp:TableHeaderCell Text="End time" /&gt;
                          &lt;/asp:TableHeaderRow&gt;
                      &lt;/asp:Table&gt;
                      &lt;asp:Button ID="btnNewSlot" runat="server" OnClick="btnNewSlot_Click" Text="New Slot" /&gt;
  
          &lt;/div&gt;&lt;/ContentTemplate&gt;
              &lt;/asp:UpdatePanel&gt;
  </code></pre>