title: Click event for dynamically created array of buttons
body: <p>In my application i have array of buttons created dynamically.I am trying to raise an onclick event for those buttons and change the text of the button which i click.I tried the below code for this but its not working.How can i do this?.Any suggesions?</p>
  
  <p><strong>Code</strong>:</p>
  
  <pre><code>   for (int i = 0; i &lt; 5; i++)
      {
          lbl = new Button[5];
          lbl[i] = new Button();
          lbl[i].Text = "hi";
          lbl[i].Width = 30;
          lbl[i].Click += new EventHandler(lbl_click);
          //lbl[i].CssClass = "label";
          div1.Controls.Add(lbl[i]);
      }
  </code></pre>
  
  <p><strong>Click Event</strong>:</p>
  
  <pre><code>   protected void lbl_click(object sender, EventArgs e)
     {
      Button[] lbl = sender as button[];
      lbl[i].Text = "clicked";
  
     }
  </code></pre>