xtrareports-devexpress-dot-xtrareports-dot-datasourcemanager-dot-replacedatasource-x28-devexpress-dot-xtrareports-dot-ui-dot-xtrareport-system-dot-object-system-dot-object-system-dot-boolean-x29.md
Replaces a report’s current data source with the specified data source.
Namespace : DevExpress.XtraReports
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public static void ReplaceDataSource(
XtraReport report,
object oldDataSource,
object newDataSource,
bool includeSubReports = false
)
Public Shared Sub ReplaceDataSource(
report As XtraReport,
oldDataSource As Object,
newDataSource As Object,
includeSubReports As Boolean = False
)
| Name | Type | Description |
|---|---|---|
| report | XtraReport |
A report instance.
| | oldDataSource | Object |
The report’s data source.
| | newDataSource | Object |
A new report data source.
|
| Name | Type | Default | Description |
|---|---|---|---|
| includeSubReports | Boolean | False |
true to replace data sources of subreports with the specified data source; otherwise, false.
|
Consider the following specifics when you use the ReplaceDataSource method:
ReplaceDataSource method to assign it to the report.The following code sample shows how to replace a report’s initial data source with a JSON data source:
using DevExpress.XtraReports;
using DevExpress.DataAccess.Json;
//...
var report = new XtraReport1();
var jsonDataSource = new JsonDataSource;
DataSourceManager.ReplaceDataSource(report, report.DataSource, jsonDataSource);
Imports DevExpress.XtraReports
Imports DevExpress.DataAccess.Json
'...
Private report = New XtraReport1()
Private jsonDataSource = New JsonDataSource()
DataSourceManager.ReplaceDataSource(report, report.DataSource, jsonDataSource)
See Also