How to Simulate Click Event on DG LinkButton?

  • Thread starter cluelis via .NET 247
  • Start date
C

cluelis via .NET 247

How can I programmatically simulate a click event on a datagrid linkbutton?

I change the text of a linkbutton in a datagrid, then need to do some processing as though the user had clicked the linkbutton with the new text.

I thought I could do it like this:

***
// get datagrid item (row)
DataGridItem dgRow = dgTxnHistory.Items[ dgRowIndex ];

// change linkbutton in this datagrid row to show 'view' (it was 'edit')
LinkButton linkButton =
( ( Linkbutton ) dgRow.Cells[ 9 ].Controls[ 0 ] );
linkButton.Text = "View";

// 'click' the above linkbutton
dgTxnHistory_ItemCommand( object source, DataGridCommandEventArgs e );
***

But, I have no idea what to put in the 'source' and 'e' parameter positions. I tried using linkButton.Click, too, but that gave me an error.

I'd appreciate any help you can offer!
 
A

Alvin Bruney [MVP]

it's just a method call. if you aren't using source and e, you can pass in
null although that's bad for scalability. Source is whatever fired the
object, so it would be an instance of the datagrid. the event args hold the
arguments so you may want to create an object of type
datagridcommandeventargs and fill it with stuff and pass in the instance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top