The method essentially binds the Grid View with a Data View.The Data View supplies all the records from the Employees table.
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).
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.
The simplest way of doing this is from within the Row Created event: When the row has been updated we need to clear the Edit mode flag and set the pages Dirty state to True.
This can be done in the Row Updated event which is fired when the user clicks the OK button of a row in Edit Mode.
The Page Index Changing event handler receives an event argument of type Grid View Page Event Args.
This argument provides the new page number that the user has selected via a property called New Page Index.
I had to wire up the dirty checking to flag any changes made to the data it contained.