Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Datagrid wire SelectedIndexChanged event from linkbutton (http://www.velocityreviews.com/forums/t104277-datagrid-wire-selectedindexchanged-event-from-linkbutton.html)

Alex 06-08-2005 03:05 PM

Datagrid wire SelectedIndexChanged event from linkbutton
 
I have a datagrid with some dynamically generated columns containing
linkButtons. How can I wire these events to fire the
datagrid_SelectedIndexChanged?

When clicking a template column defined in the IDE it works fine, the
event fires. However, anything that I add in code does not fire this
event?

Any idea?

Thanks

Alex


=?Utf-8?B?SmFzb24gTCBMaW5k?= 06-08-2005 04:20 PM

RE: Datagrid wire SelectedIndexChanged event from linkbutton
 
I should note that generally speaking, adding controls to a datagrid like you
are doing is not a good idea. Your code is generally much cleaner if you use
template columns. I have not checked this code, but this should work:
lkButton.Click += new EventHandler(DataGrid1_SelectedIndexChanged);

where lkButton is your Button and DataGrid1_SelectedIndexChanged is your
datagrid selected index changed method. It is important to note that the
sender object will be a LinkButton and not a DataGrid row or anything like
that.

Hope that helps!

Jason Lind

"Alex" wrote:

> I have a datagrid with some dynamically generated columns containing
> linkButtons. How can I wire these events to fire the
> datagrid_SelectedIndexChanged?
>
> When clicking a template column defined in the IDE it works fine, the
> event fires. However, anything that I add in code does not fire this
> event?
>
> Any idea?
>
> Thanks
>
> Alex
>
>


Alex 06-08-2005 04:30 PM

Re: Datagrid wire SelectedIndexChanged event from linkbutton
 
Jason,

Thanks for the reply. I am using a Template column in code to add the
columns. How can I have the button inside my template column fire the
datagrid SelectedIndexChanged?

Thanks

Alex



All times are GMT. The time now is 08:11 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.