Hi,
you would need to take a bit advanced approach so that control gets
recreated on postback (just ItemdataBound is not enough, since control is
not recreated without redatabinding, and that prevents postback event from
working)
Here's a post at ASP.NET Forums which should cover all you need to make it
work
Dynamically Created Controls in a Datagrid
http://forums.asp.net/745492/ShowPost.aspx
After that getting (Link)Button's Click would be either handling ItemCommand
event in the grid or wiring an event handler method to the control in code
such as
AddHandler linkButton.Click, AddressOf linkButton_Click
where linkButton_Click is a event handler method you need to write for it
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"geronimi" <we******@hotmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I want to create a linkbutton in a cell because not every row needs one
(so I can't setup a linkbuttoncolumn instead of a boundcolumn.)
First, i create a linkbutton in the datagrid_ItemDataBound :
Dim linkButton As New LinkButton
linkButton.Text = name
linkButton.CommandName = "PassSelectedClient"
linkButton.CommandArgument = id
I add it to the controls
e.Item.Cells(0).Controls.Add(linkButton)
Everything is done well, but I need something to catch the click!
I tried to add WithEvents but it can not be done with Dim
So i created this as a global: Protected WithEvents linkButton As New
KeepIT.WEBGUI.Controls.dcaLinkButton, but then my page is not rendered
well (only the last row contains a link :( )
How can I make it work with the click?