Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid wire SelectedIndexChanged event from linkbutton

Reply
Thread Tools

Datagrid wire SelectedIndexChanged event from linkbutton

 
 
Alex
Guest
Posts: n/a
 
      06-08-2005
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmFzb24gTCBMaW5k?=
Guest
Posts: n/a
 
      06-08-2005
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
>
>

 
Reply With Quote
 
 
 
 
Alex
Guest
Posts: n/a
 
      06-08-2005
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

 
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
Wire up a click event within another click event doesn't work... Chu ASP .Net 2 04-10-2006 10:43 PM
DMA 40-pin/80-Wire with a empty spot on one wire? lcs A+ Certification 1 02-02-2006 09:06 AM
DataGrid help on Datagrid's SelectedIndexChanged event Eric ASP .Net Web Controls 1 05-21-2005 05:15 AM
2 Wire and 3 Wire Telecom Wiring SchoolTech NZ Computing 1 02-26-2005 08:23 AM
how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column Dave M ASP .Net Datagrid Control 0 12-14-2004 11:53 AM



Advertisments