Question

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 (i.e. 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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top