title: asp.net - Button event does not fire up
body: <p>I have a search button on my page that runs a query on a DB, pulls out and displays some entries in a table, and for each entry I create a button. It looks something like this:</p>
  
  <pre><code>List&lt;Friend&gt; friends = SearchFriend(searchStr);
  foreach (Friend f in friends)
  {
      TableCell addCell = new TableCell(), nameCell = new TableCell();
  
      addCell.Text = "";
      if (!f.IsMyFriend)
      {
              LinkButton addFriendBtn = new LinkButton();
              addFriendBtn.Text = "Add as Friend";
              addFriendBtn.Click += new EventHandler(addFriendBtn_Click);
              addFriendBtn.ID = "add_" + f.ID.ToString();
  
              addCell.Controls.Add(addFriendBtn);
      }
      nameCell.Text = f.Name;
  
      TableRow row = new TableRow();
      row.Cells.Add(addCell);
      row.Cells.Add(nameCell);
  
      SearchFriendTable.Rows.Add(row);
  }
  </code></pre>
  
  <p>Problem is that the LinkButton event does not fire when it is pressed (changing LinkButton to a simple Button does not fix this either).</p>
  
  <p>This is the html that I get in this portion:</p>
  
  <pre><code>&lt;td&gt;&lt;a id="ctl00_contentPH_add_2" href="javascript:__doPostBack('ctl00$contentPH$add_2','')"&gt;Add as Friend&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  
  <p>Also - when I put a breakpoint on Page_Load I do see the __EVENTTARGET with this control's id in it - however the event never starts running.</p>
  
  <p>Any clues?
  Thanks.</p>