[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Chart Control
  [Collapse]Pivot Grid
   [Expand]Getting Started
   [Collapse]Binding to Data
     Binding to Data Overview
    [Expand]OLAP Data Source
    [Expand]Database Server Mode
     Unbound Fields
   [Expand]Data Shaping
   [Expand]Data Analysis
   [Expand]Data Formatting
   [Expand]Design-Time Features
   [Expand]UI Elements
   [Expand]End-User Capabilities
   [Expand]Member Tables
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Binding to Data Overview

The ASPxPivotGrid control should be connected to an external data source that provides data you wish to display and process. Like other data-bound web server controls, ASPxPivotGrid can be bound to any standard data source type, including SqlDataSource, ObjectDataSource, XmlDataSource and AccessDataSource. As an alternative, you can use specific DevExpress components to bind the Pivot Grid to data (such as the EntityServerModeDataSource or LinqServerModeDataSource components that can be used to perform data processing server side).

Expanded Bind a Pivot Grid to Data at Design Time

To bind an ASPxPivotGrid to a data source at design time, click its smart tag and select one of the following options.

  • The Choose Data Source combo box allows you to select the existing project data source.
    If necessary, you can create a new data source using the New Data Source... command.

  • Choose OLAP Data Source allows you to connect to a cube in a Microsoft Analysis Services server. To learn more, see OLAP Data Source.

After connecting the pivot grid to a data source, create the required fields. To do this, invoke the Fields and Groups page and click the Retrieve Fields button (the icon).

Automatically created fields are located in the Filter Header Area by default. To rearrange fields and locate them in the required areas, use the PivotGridFieldBase.Area property.

To learn more about pivot grid fields, see Fields.

Expanded Bind a Pivot Grid to Data in Code

To bind ASPxPivotGrid to a data source at runtime, assign the data source (for example, an AccessDataSource instance) to the ASPxPivotGrid.DataSource property.

You can create pivot grid fields automatically for all data source fields using the ASPxPivotGrid.RetrieveFields method, or populate the ASPxPivotGrid.Fields collection manually with PivotGridField instances bound to specific data source fields.

To learn more about how to create and arrange pivot grid fields, see Fields.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E2986.

This example demonstrates how to create an ASPxPivotGrid and bind it to data in code.

In this example, the ASPxPivotGrid and System.Web.UI.WebControls.AccessDataSource instances are created and initialized in code. The Pivot Grid is bound to data by assigning the AccessDataSource instance to the ASPxPivotGrid.DataSource property. Then, the ASPxPivotGrid.RetrieveFields method is used to create pivot grid fields for all data source fields.

Is this topic helpful?​​​​​​​