简体   繁体   中英

Execute method after gridview update

I have a GridView that makes use of an ObjectDataSource that references a class that updates, creates, deletes and views info, each in its own method that calls a stored procedure to do the desired operation. I also have a hidden control on the page that holds a set of Id's that i send to the SELECT method in the class that is used in the stored procedure to load the data.

I set the value of this hidden control in the Page_Load event. This means that if I update a field in the GridView (ie changing one of the ID's) the control still has the old set of ID's. I need to run the method in my code-behind after the GridView is updated in order to load the correct new results.

I've been debugging and noticed that the SELECT method in the class connected to the ObjectDataSource is called just after the UPDATE method in the same class. How can I call a method in the code-behind just before this SELECT ?

Try binding to the DataGridView.SelectedIndexChanging event ( list of all events ). MSDN states:

Occurs when a row's Select button is clicked, but before the GridView control handles the select operation.

Another helpfull event could be probably the DataBinding event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM