0
votes

I need some help to bind my dynamically created linkbutton to an event when clicked (inside a gridview)...

I saw many questions about that but always says that can be used the .OnClick += New EventHandler(event) and actually I've not the ".OnClick" property to use, I just have the OnClientClick property that can't be used by the EventHandler, here is the custom answers and what I need:

Custom answers on web:

 Dim lb As New LinkButton
 lb.Text = "Add"
 lb.OnClick += New EventHandler(lb_Click)
 grid1.FooterRow.Cells(0).Controls.Add(lb)

What I need is something like that but with a correct property that can fire an event.

2

2 Answers

0
votes

Try the "Click" event instead, i.e.

lb.Click += new EventHandler(lb_Click)
0
votes

For grid view attach a ItemDataBound event and in itemDataBound event get the link button and attach event with each link button.