Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DataSourceManager.GetDataSourceAssignables<TDataSourceAssignable>(XtraReport, Boolean) Method

Returns a report and its elements (subreports, controls, bands, parameters) that match the specified type and to which a data source can be assigned.

Namespace: DevExpress.XtraReports

Assembly: DevExpress.XtraReports.v24.2.dll

NuGet Package: DevExpress.Reporting.Core

#Declaration

public static IEnumerable<TDataSourceAssignable> GetDataSourceAssignables<TDataSourceAssignable>(
    XtraReport report,
    bool includeSubReports = false
)
    where TDataSourceAssignable : class, IDataSourceAssignable

#Parameters

Name Type Description
report XtraReport

A report instance

#Optional Parameters

Name Type Default Description
includeSubReports Boolean False

true to include elements from the subreports; otherwise, false.

#Type Parameters

Name Description
TDataSourceAssignable

The type of report elements.

#Returns

Type Description
IEnumerable<TDataSourceAssignable>

A collection that includes the report and its elements.

#Example

The following code sample shows how to retrieve a report and all its subreports (elements of the XtraReport type) and update settings (the ConnectionName property) of their data sources. In this example, we assume that the type of each data source is SqlDataSource.

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

var report = new XtraReport1();

var dataBoundReports = DataSourceManager.GetDataSourceAssignables<XtraReport>(
    report: report,
    includeSubReports: true
);

foreach (var dataBoundReport in dataBoundReports) {
    (dataBoundReport.DataSource as SqlDataSource).ConnectionName = "nwind";
}
See Also