title: asp.net event handler when click on link button dynamically
body: <p>hello everyone i just start programming in asp.net i struggling to add event handler dynamically. here is the scenario when the aspx page is load a link button is add with an event handler</p>
  
  <p>page load add link button and event handler with link button</p>
  
  <hr>
  
  <p>Dim products As New LinkButton</p>
  
  <p>products.Text = "Products"</p>
  
  <p>testPanel.Controls.Add(products)</p>
  
  <p>AddHandler products.Click, AddressOf getProducts</p>
  
  <hr>
  
  <p>the getProducts function will loop in the database get all the product </p>
  
  <pre><code>    Dim testDb As New Product
      Dim arr As ArrayList = testDb.DbLoop()
      Dim ObjList As ProductBo
      Dim ID As Integer
      Dim link As LinkButton
  
  
  
      For Each ObjtList In arr
  
          ID= ObjtList.C_Id
          link = New LinkButton
          testPanel.Controls.Add(New LiteralControl("&lt;br /&gt;"))
          link.ID = ID
          link.Text = ObjList.Name
          link.CommandArgument = CustInt
          Me.testPanel.Controls.Add(link)
          AddHandler link.Click, AddressOf getProductsDetails
      Next ObjList
  </code></pre>
  
  <p>HERE IS MY problem after looping it will display a list of product in the database, what i want to do add a link of each product name when i click on one product it should invoke another event handler i try this one but it not working.</p>
  
  <p>AddHandler link.Click, AddressOf getProductsDetails</p>
  
  <p>thank you</p>