title: add controls to innerhtml div inside table
body: <p>Inside a div I'm trying to add a table from codebehind.
  I need to add 2 controls to this table so in order to do this I put the code in the <code>Page_Init()</code> but it won't add the controls so what should I do to resolve this or should I go a completely different way.</p>
  
  <p>my code:</p>
  
  <pre><code>if ((List&lt;ShoppingCart&gt;)Session["shoppin"] != null)
          {
              string cartcontent = "";
              TextBox txtbox = new TextBox();
              txtbox.TextChanged +=new EventHandler(txtbox_TextChanged);
              txtbox.CssClass = "carttextbox";
              Button btn = new Button();
              btn.Click +=new EventHandler(btn_Click);
              btn.Text = "Remove";
              btn.CssClass = "cartbtn";
              maincontent.Controls.Add(txtbox);
              maincontent.Controls.Add(btn);
  
              foreach (ShoppingCart r in (List&lt;ShoppingCart&gt;)Session["shoppin"])
              {
                  cartcontent = cartcontent + "&lt;tr class='row'&gt;" +
                      "&lt;td class='cart_prods'&gt;" +
                      "&lt;table&gt;" +
                      "&lt;tr&gt;" +
                      "&lt;td colspan='2'&gt;&lt;b&gt;" + r.ProductName + "&lt;/b&gt;&lt;/td&gt;" +
                      "&lt;/tr&gt;" +
                      "&lt;tr&gt;" +
                      "&lt;td align='center' style='width:100%'&gt; &lt;img src='" + r.ProductImage + "' alt='' style='max-height:150px' /&gt;&lt;/td&gt;" +
                      "&lt;td&gt;&lt;div class='.cart_products_options'&gt;&lt;i&gt;" + r.ProductOptions + "&lt;/i&gt;&lt;/div&gt;&lt;/td&gt;" +
                      "&lt;/tr&gt;" +
                      "&lt;/table&gt;" +
                      "&lt;/td&gt;" +
                      "&lt;td class='cart_update' style='border-width: 0px 1px 1px 0px;'&gt;" + txtbox + btn + "&lt;/td&gt;" + 
                      "&lt;td class='cart_price' style='border-width: 0px 0px 1px;'&gt;&lt;span class='ProductSpecialPrice'&gt; $"+ r.ProductPrice + "&lt;/span&gt;&lt;/td&gt;"
                      +"&lt;/tr&gt;";
                  double pricetotal = 0;
                  pricetotal = pricetotal + r.ProductPrice;
              }
  
              maincontent.InnerHtml = "&lt;table width='90%' style='margin:0 auto; margin-top:50px;' class='cart'&gt;" +
                  "&lt;tr align='center'&gt;" +
                      "&lt;th class='th1'&gt;&lt;b&gt;Product(s)&lt;/b&gt;&lt;/th&gt;" +
                      "&lt;th&gt;&lt;b&gt;Qty&lt;/b&gt;&lt;/th&gt;" +
                      "&lt;th class='th3'&gt;&lt;b&gt;Total&lt;/b&gt;&lt;/th&gt;" +
                  "&lt;/tr&gt;" + cartcontent +
                  "&lt;tr class='cart_total'&gt;" +
                      "&lt;td&gt;&lt;/td&gt;" +
                      "&lt;td style='border-width: 1px 1px 0px 0px; text-align:right;'&gt;Sub-Total&lt;/td&gt;" +
                      "&lt;td&gt;&lt;/td&gt;" +
                  "&lt;/tr&gt;" +
              "&lt;/table&gt;";
          }
  </code></pre>