event is raised when a button listed in the previous table is clicked, it is recommended that you use the events listed in the table for the operation.

rowupdating in gridview in asp net example-33

Fortunately Grid View can also be used without attaching with the Data Source Controls. In this article we will see how paging, sorting and editing can be implemented in a Grid View control that is bound with a Data View (or Data Table) directly.

This calls for some extra coding from developer's end. As an example we are going to use Employees table of the Northwind database. Add three Bound Fields and a Command Field to the Grid View with the help of Fields dialog (see below).

The Cancel property allows you to cancel the sorting operation.

Since we are not using data source controls we need to handle the toggling of the sort direction on our own. Add the following code in the Sorting event handler.

This enables you to provide an event-handling method that performs a custom routine whenever this event occurs.

Buttons within a Grid View control can also invoke some of the built-in functionality of the control.

To perform one of these operations, set the Command Name property of a button to one of the values in the following table. Sets the Command Argument property of the button to "First", "Last", "Next", "Prev", or a page number to specify the type of paging operation to perform.

Raises the Page Index Changing and Page Index Changed events.

There are many articles and tutorials around that illustrate the use of Grid View control along with the new Data Source Controls.

When attached with a Data Source control Grid View performs tasks such as paging, sorting and editing automatically i.e. However, at times you require to bind the Grid View with a Data View or Data Table directly.

Once you set these properties you will find that the column headers of all the columns for which you specified Sort Expression property appear as clickable link buttons.