Exploring Cool Features of Devexpress' ASPxGridView, Page 4
Figure 4: Configure the XpoDataSource to include ServerMode and the complete name of the persistent class generated earlier.
Figure 5: Indicate that the grid is getting its data from the XpoDataSource by setting the DataSourceID property as shown.
Listing 3: Add this code to the default.aspx.vb source file.
Protected Sub Page_Init(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.Init XpoDataSource1.Session = New DevExpress.Xpo.Session End Sub
Page_Init has the same signature as the Page_Load, so you can copy and paste Page_Load and change the subroutine name and the handles clause to indicate that this subroutine handles the Page_Init behavior. This very simple statement establishes session storage for the XpoDataSource. Run the solution and you should see a web page that looks similar to the result shown in Figure 6.
Figure 6: About eight lines of code and a few minutes of drag and drop practice and you can get a result similar to that shown using the ASPxGridView and XpoDataSource from Developer Express.
The XpoDataSource ServerMode property pushes managing how much data is returned to the client back to the server. As a result, if you returned a table that contains thousands of rows, only those displayed in the grid at a given time will be returned to the client. ServerMode means that managing how and when subsets of data are retrieved from the database is managed by XPO, so you and I don't have to write that code.
Sorting the ASPxGridView at Runtime
The ASPxGridView supports sorting by default, and sorting is enabled by default. All the user has to do to use the sort behavior is click a column header. Clicking a column header will cause the data to be sorted on that column. Click the column a subsequent time and the sort order will be reversed. Hold the Shift key and click another column, and you will create a secondary sort on that column. A small icon on the right-hand side of the column header will indicate which column is being sorted and the triangular icon indicates the direction. (The triangle pointing up in Figure 6 in the Product Name column indicates that the grid is sorted on the Product Name column in ascending order.)
Page 4 of 6