In this example, I am going to retrieve values from categories table of Northwind database. Drag a Grid View into the Web Form and assign Data Key Names property with the primary key column i.e. In the gdview_Row Editing and gdview_Row Deleting event, we have used the below code to retrieve categoryid from datakey of Grid View, int catid = int.
Similarly we set a View State variable called sortdirection. In order to edit records displayed in the Grid View, we need to add a Command Field to the Grid View.
They are: The former event is raised before the current page changes and the later is raised after the page has changed. Write the following code in the Page Index Changing event of the Grid View.
The Page Index Changing event handler receives an event argument of type Grid View Page Event Args.
Clicking on the link buttons raise two events: Just like paging events these events follow pre and post pattern.
The Sorting event allows you to cancel the operation also.