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

IReportDesignerModelBuilder.DataSources(IDictionary<String, Object>) Method

Registers data sources so that they are available in Web Report Designer when you edit reports.

Namespace: DevExpress.XtraReports.Web.ReportDesigner.Services

Assembly: DevExpress.XtraReports.v24.2.Web.dll

NuGet Package: DevExpress.Web.Reporting.Common

#Declaration

IReportDesignerModelBuilder DataSources(
    IDictionary<string, object> dataSources
)

#Parameters

Name Type Description
dataSources IDictionary<String, Object>

A data source dictionary where the key is the name of the data source and the value is an instance of the data source.

#Returns

Type Description
IReportDesignerModelBuilder

A IReportDesignerModelBuilder that can be used to further configure the Report Designer.

#Remarks

The following code example is the controller Action that registers data sources for use in the Web Report Designer:

public class CustomReportDesignerController : ReportDesignerController {
    public CustomReportDesignerController(IReportDesignerMvcControllerService controllerService) : base(controllerService) {
    }

    [HttpPost("[action]")]
    public IActionResult GetDesignerModel(
        [FromForm]string reportUrl, 
        [FromServices] IReportDesignerModelBuilder designerModelBuilder, 
        [FromForm] ReportDesignerSettingsBase designerModelSettings) {
        var ds = new SqlDataSource("NWindConnectionString");

        // Create a SQL query to access the Products data table.
        SelectQuery query = SelectQueryFluentBuilder.AddTable("Products").SelectAllColumnsFromTable().Build("Products");
        ds.Queries.Add(query);
        ds.RebuildResultSchema();

        var designerModel = designerModelBuilder.Report(reportUrl)
            .DataSources(dataSources => {
                dataSources.Add("Northwind", ds);
            })
            .BuildModel();
       designerModel.Assign(designerModelSettings);
       return DesignerModel(designerModel);
    }
}

For more information, review the following help topic: Data Sources in Web End-User Report Designer (ASP.NET Core).

See Also