L
leanne lis via .NET 247
How can I simulate a click on a linkbutton in a datagrid?
I've got a linkbutton with text 'edit'. The user clicks on it, does some editing, and submits. I then change the linkbutton text to 'view', and need to re-display the transaction they just edited as though they had clicked the 'view' linkbutton.
If I manually click the linkbutton, I get the results I want; so how can I do this programmatically, so the user won't have to click the linkbutton after submitting the transaction???
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'
LinkButton linkButton =
( ( LinkButton ) dgRow.Cells[ 9 ].Controls[ 0 ] );
linkButton.Text = "View";
// call ItemCommand event where transaction will be redrawn -
// dgTxnHistory_ItemCommand( object source, DataGridCommandEventArgs e )
dgTxnHistory_ItemCommand( source, e );
******
but, if that would work, what do I need in the 'source' and 'e' params? Or, is there an easier way? (I'm using C#)
thanks for any help you can offer!
I've got a linkbutton with text 'edit'. The user clicks on it, does some editing, and submits. I then change the linkbutton text to 'view', and need to re-display the transaction they just edited as though they had clicked the 'view' linkbutton.
If I manually click the linkbutton, I get the results I want; so how can I do this programmatically, so the user won't have to click the linkbutton after submitting the transaction???
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'
LinkButton linkButton =
( ( LinkButton ) dgRow.Cells[ 9 ].Controls[ 0 ] );
linkButton.Text = "View";
// call ItemCommand event where transaction will be redrawn -
// dgTxnHistory_ItemCommand( object source, DataGridCommandEventArgs e )
dgTxnHistory_ItemCommand( source, e );
******
but, if that would work, what do I need in the 'source' and 'e' params? Or, is there an easier way? (I'm using C#)
thanks for any help you can offer!