title: Asp.net create LinkButton and attach onclick event when another LinkButton is clicked
body: <p>So.. I'm dynamically creating LinkButtons on my page like this:</p>
  
  <pre><code>LinkButton lb = new LinkButton();
  lb.Click += new EventHandler(lb_Click);
  </code></pre>
  
  <p>When one of these LinkButtons is clicked, I need to know which one the links was clicked, then create another LinkButton and attach an onclick event on it. (How) can I do this? If I have understood correctly, click events can't be attached in (this case in) lb_Click function, so is there any way I still could do this?</p>
  
  <p>Edited:</p>
  
  <p>To make this problem more understandable, here's how I tried to make it but it does not work:</p>
  
  <pre><code>LinkButton lb = new LinkButton();
  lb.click += new EventHandler(lb_Click);
  
  void lb_Click(object sender, EventArgs e)
  {
      LinkButton lb2 = new LinkButton();
      lb2.click += new EventHandler(lb2_Click);
  }
  
  void lb2_Click(object sender, EventArgs e)
  {
      //do something
  }
  </code></pre>
  
  <p>Clicking lb2 does not fire the lb2_Click event.</p>