Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Create linkbutton in datagrid_ItemDataBound event, how catch click?

Reply
Thread Tools

Re: Create linkbutton in datagrid_ItemDataBound event, how catch click?

 
 
Teemu Keiski
Guest
Posts: n/a
 
      01-02-2006
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" <> wrote in message
news: 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?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid_ItemDataBound =?Utf-8?B?cm9kY2hhcg==?= ASP .Net 1 09-10-2005 08:00 PM
Linkbutton does not look like a linkbutton Sathyaish ASP .Net 3 09-08-2005 09:41 AM
Linkbutton does not look like a linkbutton Sathyaish ASP .Net Datagrid Control 1 09-08-2005 08:44 AM
datagrid_ItemDataBound question =?Utf-8?B?cm9kY2hhcg==?= ASP .Net 2 11-24-2004 01:31 AM
dataGrid_ItemDataBound - System.InvalidCastException AZNewsh ASP .Net Datagrid Control 1 11-18-2004 05:31 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57