title: Add asp controls dynamically using AJAX
body: <p>I want to make the <strong>+Add more original use</strong> LinkButton!</p>
  
  <p><img src="https://i.stack.imgur.com/vNdtY.png" alt="enter image description here"></p>
  
  <p>I have this row on my table I am using:  </p>
  
  <p>
          </p>
  
  <pre><code>        &lt;asp:Label ID="Label43" runat="server" 
              Text="P-2.5 Original use:"&gt;&lt;/asp:Label&gt;
      &lt;/td&gt;
      &lt;td class="style1"&gt;
  
              &lt;div style="float:left;"&gt;
              &lt;asp:DropDownList class="text-input" ID="DDLOriginalUse" runat="server"
                          DataSourceID="SqlDataSource5" DataTextField="DESCRIPTION" 
                          DataValueField="ID_PROGRAM_USE" OnSelectedIndexChanged="itemSelected" AutoPostBack="True" AppendDataBoundItems="true"&gt;
                          &lt;asp:ListItem Text="-Not assigned-" Value="-1" Selected="True" /&gt;
              &lt;/asp:DropDownList&gt;
              &lt;/div&gt;
  
              &lt;asp:UpdatePanel runat="server" style="float:left;" id="UpdatePanel2" updatemode="Conditional"&gt;
                  &lt;Triggers&gt;
                      &lt;asp:AsyncPostBackTrigger controlid="DDLOriginalUse" eventname="SelectedIndexChanged" /&gt;
                  &lt;/Triggers&gt;
                  &lt;ContentTemplate&gt;
                      &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;asp:Label ID="lblProgramType" runat="server"&gt;&lt;/asp:Label&gt;
                  &lt;/ContentTemplate&gt;
              &lt;/asp:UpdatePanel&gt;
  
          &lt;asp:SqlDataSource ID="SqlDataSource5" runat="server" 
              ConnectionString="&lt;%$ ConnectionStrings:MesarchConnectionString %&gt;" 
              SelectCommand="SELECT * FROM [PROGRAM_USE]"&gt;&lt;/asp:SqlDataSource&gt;
  
      &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>I want to add new rows with the same content as above so I am using an asp:PlaceHolder :
  this code continues..</p>
  
  <pre><code>&lt;/tr&gt;
  
  &lt;asp:UpdatePanel runat="server" id="UpdatePanel1" updatemode="Conditional"&gt;
      &lt;Triggers&gt;
          &lt;asp:AsyncPostBackTrigger controlid="LinkButtonAddOriginal" eventname="Click" /&gt;
      &lt;/Triggers&gt;
      &lt;ContentTemplate&gt;
              &lt;asp:PlaceHolder ID="PlaceHolderAddNewOriginalUse" runat="server"&gt;&lt;/asp:PlaceHolder&gt;
  
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  
  &lt;tr&gt;
      &lt;td&gt;
          &amp;nbsp;&lt;/td&gt;
      &lt;td class="style1"&gt;
          &lt;asp:UpdatePanel runat="server" id="UpdatePanel3" updatemode="Conditional"&gt;
              &lt;Triggers&gt;
                  &lt;asp:AsyncPostBackTrigger controlid="LinkButtonAddOriginal" eventname="Click" /&gt;
              &lt;/Triggers&gt;
              &lt;ContentTemplate&gt;
                      &lt;b&gt;&lt;asp:LinkButton ID="LinkButtonAddOriginal" OnClick="AddMoreOriginal" runat="server"&gt;+Add more original use&lt;/asp:LinkButton&gt;&lt;/b&gt;
              &lt;/ContentTemplate&gt;
          &lt;/asp:UpdatePanel&gt;
  
      &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>and in my code behind I am doing this for the click(I want to add maximum 5 text boxes):</p>
  
  <pre><code>private static int countOriginalUse = 1;
  
  private static LiteralControl htmlPresentation = new LiteralControl();
  
  protected void AddMoreOriginal(object sender, EventArgs e)
      {
          StringBuilder str_for_ltr = new StringBuilder();
          countOriginalUse++;
          if (countOriginalUse &gt;= 6) { LinkButtonAddOriginal.Text = "You can not add more.";return; }
  
          str_for_ltr.Append("&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;P-2.5 Original use " + countOriginalUse.ToString() + ":&lt;/td&gt;");
          str_for_ltr.Append("&lt;td class='style1'&gt;");
  
  
          str_for_ltr.Append("&lt;/td&gt;");
          str_for_ltr.Append("&lt;/tr&gt;");
  
  
          htmlPresentation.Text += str_for_ltr.ToString();
  
          PlaceHolderAddNewOriginalUse.Controls.Add(htmlPresentation);
  
          /*DropDownList ddl1 = new DropDownList();
          ddl1.ID="Dropdown1";
          ddl1.CssClass = "Mycss";
          ddl1.Items.Add("test");
          PlaceHolderAddNewOriginalUse.Controls.Add(ddl1);
          PlaceHolderAddNewOriginalUse.Controls.Add(new LiteralControl("&lt;br/&gt;"));*/
      }
  </code></pre>
  
  <p>So the problems I face here are that it does not adds new rows, and even the text is not where I placed my asp:PlaceHolder (is on the top).</p>
  
  <p>And surely I will have more problems when I will have to add this DropDownList with also a UpdatePanel for it(as shown on my first code).</p>
  
  <p>Am I doing it totally wrong, do I have to follow some other way to do it?
  I am confused...</p>