The requested page is not available for the requested platform. You are viewing the content for Default platform.

Bind a Report to a DataSet

  • 4 min to read

This topic explains how to bind a report to a DataSet object.


The Data Source Wizard does not support binding to a DataSet. To use the Data Source Wizard, consider the other data providers.

Design Time Binding

Do the following to bind a report to a DataSet object at design time in Visual Studio:

  1. Start Microsoft Visual Studio and create a new application or open an existing application.

  2. Select Add New Data Source on the Project menu.


  3. From the invoked Data Source Configuration Wizard, select Database and click Next.


  4. Choose the Dataset as a database model. Click Next.


  5. On the next page, click New Connection.


  6. In this example, the report is bound to a sample Northwind database hosted on a Microsoft SQL Server. Specify the connection options. Click OK.


  7. Click Next to connect to the database.

  8. On the next page, choose which object to add to the dataset. Expand the Tables category, select the Categories item and click Finish to exit the wizard.


  9. Add a new blank report to the application.

  10. Click the report's smart tag. In the invoked actions list, choose DataSource - Project Options - NWindDataSet.

    bind-a-report-to-dataset-07 bind-a-report-to-dataset-08

  11. The report is now bound to data. The Report Explorer displays the data source in the Components node. The Field List reflects the data source's hierarchy.


Runtime Binding

The following example demonstrates how to bind a report to a DataSet object at runtime:

using DevExpress.XtraReports.UI;
public partial class Form1 : Form
    public Form1()
        ReportDesignTool designTool = new ReportDesignTool(CreateReport());

    XtraReport CreateReport()
        // Create a dataset.           
        DataSet ds = FillDataset();
        // Define a report
        XtraReport report = new XtraReport()
            DataSource = ds,
            DataMember = ds.Tables[0].TableName,
            Bands = {
                new DetailBand()
                    Controls = {
        return report;

    XRLabel CreateLabel()
        ExpressionBinding eb = new ExpressionBinding("BeforePrint", "Text", "[ProductId] + ' | ' + [ProductName] + ' | ' + [SupplierId] + ' | ' + [Category]");
        XRLabel lb = new XRLabel { Left = 30, WidthF = 300 };
        return lb;

    public DataSet FillDataset()
        DataSet dataSet1 = new DataSet();
        dataSet1.DataSetName = "nwindDataSet1";
        DataTable dataTable1 = new DataTable();


        dataTable1.TableName = "Products";
        dataTable1.Columns.Add("ProductId", typeof(int));
        dataTable1.Columns.Add("ProductName", typeof(string));
        dataTable1.Columns.Add("SupplierId", typeof(int));
        dataTable1.Columns.Add("Category", typeof(int));

        dataSet1.Tables["Products"].Rows.Add(new Object[] { 1, "Chai", 1, 1 });
        dataSet1.Tables["Products"].Rows.Add(new Object[] { 2, "Chang", 1, 1 });
        dataSet1.Tables["Products"].Rows.Add(new Object[] { 3, "Aniseed Syrup", 1, 2 });
        dataSet1.Tables["Products"].Rows.Add(new Object[] { 4, "Chef Anton's Cajun Seasoning", 2, 2 });
        dataSet1.Tables["Products"].Rows.Add(new Object[] { 5, "Chef Anton's Gumbo Mix", 2, 2 });
        return dataSet1;


The following image demonstrates the resulting Field List: