Lesson 1 - Bind a Pivot Grid to an MDB Database

  • 3 minutes to read

This tutorial shows how to add an ASPxPivotGrid to a new ASP.NET application, bind it to a database and create pivot grid fields mapped to appropriate fields from the database. In this example, a Northwind.mdb database is used to supply the ASPxPivotGrid with data.

Steps 1-6. Create a New Project and Add ASPxPivotGrid to it

  1. Run MS Visual Studio.
  2. Create a new project by selecting File | New | Project… In the invoked New Project dialog, select the Web section, and choose the DevExpress v21.2 Template Gallery.


  3. In the DevExpress Template Gallery, go to the ASP.NET Web Forms category and select Empty Web Application.


  4. In the DevExpress ASP.NET MVC Project Wizard, select Empty on the Choose Layout page.


    Click Create Project.

  5. Right-click the project in the Solution Explorer and select Add | Web Form from the context menu. In the invoked dialog, leave the default item name and click OK.


  6. Drag and drop the ASPxPivotGrid control from the DX.21.2: Data & Analytics toolbox tab onto the page.


Steps 7-13. Prepare a Data Source

  1. Right-click the App_Data folder and select Add | Existing Item… from the context menu. In the Add Existing Item dialog, locate the Northwind database file and click Add. You can find the database by the following path.

    C:\Users\Public\Documents\DevExpress Demos 21.2\Components\Data\nwind.mdb

  2. Click the smart tag icon displayed in the top-right corner of the pivot grid to invoke the ASPxPivotGrid Tasks popup window.


    In this window, open the Choose Data Source drop-down list and select New data source…


    This will run the Data Source Configuration wizard.

  3. On the first page, choose Database as the data source type and click OK.


  4. On the next page, select the nwind.mdb database from the list and click Next.


  5. On the next page, leave default settings and click Next.


  6. On the Configure the Select Statement page, choose the database columns that you need to include in the data source. To do this, follow the steps below.

    1. Select Specify columns from a table or view.
    2. Select SalesPerson from the Name drop-down list.
    3. Check the following columns:

      • Country
      • ProductName
      • CategoryName
      • Extended Price
      • Sales Person


    Click Next.

  7. On the last page, you can optionally test the automatically generated query using the Test Query button.


    To close the wizard, click Finish.

Steps 14-15. Create and Arrange Pivot Grid Fields

  1. Click the smart tag icon and then click Designer…. This will invoke the ASPxPivotGrid Designer.


    Click the Retrieve fields button, ensure that the Check All option is enabled, and then click OK to automatically create pivot grid fields for all data source columns.


    The PivotGridControl will locate all the created fields in the Data Header Area.

  2. Use drag-and-drop to move the fields between areas. Also, you can move the fields between the areas by using the Property pane and specifying their index within the areas (use the Area and AreaIndex properties).

    Put the CategoryName and ProductName fields (in the given order) into the Row Header Area, the Country and Sales_Person fields into the Column Header Area, and the Extended_Price field into the Data Header Area.



  1. Run the project to see the result.


See Also