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
page load add link button and event handler with link button
Dim products As New LinkButton
products.Text = "Products"
testPanel.Controls.Add(products)
AddHandler products.Click, AddressOf getProducts
the getProducts function will loop in the database get all the product
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("<br />"))
link.ID = ID
link.Text = ObjList.Name
link.CommandArgument = CustInt
Me.testPanel.Controls.Add(link)
AddHandler link.Click, AddressOf getProductsDetails
Next ObjList
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.
AddHandler link.Click, AddressOf getProductsDetails
thank you