All docs
V20.2
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

DataSourceManager Class

Allows you to get data source(s) from a report or controls.

Namespace: DevExpress.XtraReports

Assembly: DevExpress.XtraReports.v20.2.dll

Declaration

public static class DataSourceManager
Public Module DataSourceManager

Remarks

Use the static methods declared in this class to get data sources from a report and its controls/parameters, replace a data source, or add data sources to a report.

Operation Methods
Get data sources The GetDataSources overloaded methods
Get controls and parameters that have data sources The GetDataSourceAssignables overloaded methods
The GetBricksByText overloaded methods
Get controls and parameters that have the specified data source The GetDataSourceAssignablesByDataSource(XtraReport, Object, Boolean) method
Add data sources to a report The AddDataSources(XtraReport, IComponent[]) method

Example

The following code retrieves all data sources in a report and its controls, and populates these data sources with data:

using DevExpress.XtraReports.UI;
using DevExpress.DataAccess.Json;
using DevExpress.XtraReports;
// ...

// Create a report and assign a JSON data source to it.
XtraReport report = new XtraReport();
var jsonDataSource1 = new JsonDataSource();
report.DataSource = jsonDataSource1;

// Add the report's BeforePrint event handler
report.BeforePrint += PopulateDataSources;

// Create a chart and place it in the report's footer band.
DetailBand detailBand = new DetailBand();
ReportFooterBand reportFooterBand = new ReportFooterBand();
report.Bands.AddRange(new Band[] { detailBand, reportFooterBand });
XRChart chart = new XRChart();
var jsonDataSource2 = new JsonDataSource();
chart.DataSource = jsonDataSource2;
reportFooterBand.Controls.Add( chart );

// ...
// Retrieve all data sources from the report and its controls.
private void PopulateDataSources(object sender, System.Drawing.Printing.PrintEventArgs e) {
  var report = sender as XtraReport;
  var dataSources = DataSourceManager.GetDataSources(report, true);
  foreach (var dataSource in dataSources) {
    (dataSource as JsonDataSource).Fill();
  }
}

Inheritance

Object
DataSourceManager
See Also