title: Dynamic Button not triggered in ASP.Net from static class
body: <p>I am trying to make a dynamic table which has a couple of rows and the last row is a plus button, which will add a new row. (I will only describe the important information, to keep it simple.)</p>
  
  <p>I thought of this way to accomplish it:</p>
  
  <pre><code>// .aspx code 
  &lt;li&gt;&lt;asp:LinkButton ID="LM_Show" runat="server" Text="Show list" OnClick="Action"/&gt;&lt;/li&gt;
  &lt;asp:PlaceHolder ID="infoTable" runat="server"&gt;&lt;/asp:PlaceHolder&gt;
  
  //CreateTable function
  public void Clicked(object sender, EventArgs e){
      table();
  }
  public void table() {
      //Do stuff...
  
      //Screen variable is keeping track of which screen should be shown in .aspx
      infoTable.Controls.Add(CreateView.createTable&lt;Employee&gt;(screen, this.Context, table));
  }
  
  //Create the actual table 
  public static Table createTable&lt;T&gt;(Screen screen, HttpContext context, Action method) where T : new() {
      //New table and make it stretch
      Table tb = new Table();
      tb.Width = Unit.Percentage(100);
      tb.Height = Unit.Percentage(100);
  
      //Gather list from session
      List&lt;T&gt; items = (List&lt;T&gt;)context.Session["list"];
  
      //Create table content based on the list
      for (int i = 1; i &lt;= items.Count(); i++) {
          TableRow tr = new TableRow();
  
         //Foreach property create cells with content according to the property
         //Add these cells to the row
  
          tb.Rows.Add(tr);
      }
  
      //Create 1 final row which has a button to be able to add 1 row
      TableRow tr2 = new TableRow();
      TableCell tc = new TableCell();
      tr.Cells.Add(tc);
  
      //Create the Button
      Button button = new Button();
      button.Text = "+";
  
      //!!This is not getting triggered!!//
      button.Click += (s, e) =&gt; { 
          List&lt;T&gt; tempItems = (List&lt;T&gt;)context.Session["list"]; 
          tempItems.Add(new T()); 
          context.Session["list"] = tempItems; 
          //When a button is pressed, it gives a postback.
          //The table has to be rebuild over again with the newly added item
          method(); 
      };
      //!!This is not getting triggered!!//
  
      //Add the button
      tr2.Cells[0].Controls.Add(button);
      tb.Rows.Add(tr2);
  
      return tb;
  }
  </code></pre>
  
  <p><strong>Any comments about the code or how to accomplish it even better are also very welcome.</strong></p>