Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically select GridView row so that "OnSelectedIndexChanged" event fires

Tags:

c#

asp.net

I have <asp:GridView> that has a select, edit, delete and insert links within its rows. I want to trigger the OnSelectedIndexChanged after I insert a row. Can someone help??

like image 434
Samer_Azar Avatar asked Feb 17 '23 11:02

Samer_Azar


1 Answers

Simply select the row by calling the GridView.SelectRow(int rowIndex) method, passing the index of the new row. This will fire the SelectedIndexChanged event (*)

(*) To be more precise, it will first fire the SelectedIndexChanging event, then only fire SelectedIndexChanged if none of the SelectedIndexChanging event handlers has set cancel to true.

like image 89
Joe Avatar answered Feb 19 '23 00:02

Joe