Skip to main content
A newer version of this page is available. .

XtraReportBase.DataMember Property

Specifies the collection, list, or table in the object assigned to the DataSource property from which to retrieve the data.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v22.1.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

[DefaultValue("")]
[SRCategory(ReportStringId.CatData)]
public string DataMember { get; set; }

Property Value

Type Default Description
String String.Empty

The name of the collection, list, or table in the data source.

Remarks

The DataMember property specifies the collection/list in the object assigned to the report data source from which to retrieve the data.

As a general rule, when you bind a report to the database, you must specify the table name as the DataMember property value. A JSON source may have multiple data sets, all owned by the topmost root element. In this situation, you must specify the DataMember as the name of the JSON data set under the root node.

You can omit the DataMember property in some cases, such as when the object assigned to the DataSource property is a collection or list.

When you change the report data source, the DataMember property is reset, and you must explicitly specify the DataMember value. It is necessary when you use the DataSourceManager.ReplaceDataSource method to replace the data source bound to the report elements.

Review the following topics for more information:

Example

The following code example illustrates how to bind a report to the Northwind database’s Products table and display product names:

'#Region "#reference"
Imports System.Windows.Forms
Imports System
Imports DevExpress.DataAccess.Sql
Imports DevExpress.DataAccess.ConnectionParameters
Imports DevExpress.XtraReports.UI

' ...
'#End Region  ' #reference
Namespace RuntimeBindingToMdbDatabase

    Public Partial Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

'#Region "#code"
        Private Function BindToData() As SqlDataSource
            ' Create a data source with the specified connection parameters.  
            Dim connectionParameters As Access97ConnectionParameters = New Access97ConnectionParameters("../../nwind.mdb", "", "")
            Dim ds As SqlDataSource = New SqlDataSource(connectionParameters)
            ' Create an SQL query to access the Products table.
            Dim query As CustomSqlQuery = New CustomSqlQuery()
            query.Name = "customQuery"
            query.Sql = "SELECT * FROM Products"
            ' Add the query to the collection. 
            ds.Queries.Add(query)
            ' Update the data source schema.
            ds.RebuildResultSchema()
            Return ds
        End Function

        Private Function CreateReport() As XtraReport
            ' Create a new report instance.
            Dim report As XtraReport = New XtraReport()
            ' Assign the data source to the report.
            report.DataSource = BindToData()
            report.DataMember = "customQuery"
            ' Add a detail band to the report.
            Dim detailBand As DetailBand = New DetailBand()
            detailBand.Height = 50
            report.Bands.Add(detailBand)
            ' Create a new label.
            Dim label As XRLabel = New XRLabel With {.WidthF = 300}

            ' Bind the label to the data, dependent on the data binding mode.
            Dim DesignerOptions = DevExpress.XtraReports.Configuration.Settings.Default.UserDesignerOptions
            If DesignerOptions.DataBindingMode = DataBindingMode.Bindings Then
                label.DataBindings.Add("Text", Nothing, "customQuery.ProductName")
            Else
                label.ExpressionBindings.Add(New ExpressionBinding("BeforePrint", "Text", "[ProductName]"))
            End If

            ' Add the label to the detail band.
            detailBand.Controls.Add(label)
            Return report
        End Function

        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
            ' Invoke the report preview.
            Dim printTool As ReportPrintTool = New ReportPrintTool(CreateReport())
            printTool.ShowPreview()
        End Sub

        Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)
            ' Invoke the End-User Designer and load the report.
            Dim designTool As ReportDesignTool = New ReportDesignTool(CreateReport())
            designTool.ShowRibbonDesignerDialog()
        End Sub
'#End Region  ' #code
    End Class
End Namespace

The following code snippets (auto-collected from DevExpress Examples) contain references to the DataMember property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Implements

See Also