A newer version of this page is available. Switch to the current version.

XtraReportBase.DataMember Property

Gets or sets a specific list in a report’s data source.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll


public string DataMember { get; set; }

Property Value

Type Default Description


A String representing a list in a report’s XtraReportBase.DataSource.


The DataMember property specifies the list (the object of a class that implements either the IList or the IListSource interface) in the data source that is returned by the XtraReportBase.DataSource property. Note that for the XtraReport object, this property’s value is usually a data table, and for the DetailReportBand this property’s value is a master-detail relationship.


If the DataMember property is no longer valid after the XtraReportBase.DataSource property has been changed then the DataMember property will be automatically set to Empty.

See also the Bind a Report to a Data Source and Creating a Master-Detail Report using Detail Report Bands topics, to learn more about the DataMember property.


Imports System.Windows.Forms
Imports System
Imports DevExpress.DataAccess.Sql
Imports DevExpress.DataAccess.ConnectionParameters
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraReports.Configuration

' ...
Private Function BindToData() As SqlDataSource
    ' Create a data source with the required connection parameters.  
    Dim connectionParameters As New Access97ConnectionParameters("../../nwind.mdb", "", "")
    Dim ds As New SqlDataSource(connectionParameters)

    ' Create an SQL query to access the Products table.
    Dim query As New CustomSqlQuery()
    query.Name = "customQuery"
    query.Sql = "SELECT * FROM Products"

    ' Add the query to the collection and return the data source. 

    ' Make the data source structure displayed 
    ' in the Field List of an End-User Report Designer.

    Return ds
End Function

Private Function CreateReport() As XtraReport
    ' Create a new report instance.
    Dim report As 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 New DetailBand()
    detailBand.Height = 50

    ' Create a new label.
    Dim label As XRLabel = New XRLabel With {.WidthF = 300}
    ' Specify the label's binding depending on the data binding mode.
    If Settings.Default.UserDesignerOptions.DataBindingMode = DataBindingMode.Bindings Then
       label.DataBindings.Add("Text", Nothing, "customQuery.ProductName")
        label.ExpressionBindings.Add(New ExpressionBinding("BeforePrint", "Text", "[ProductName]"))
    End If
    ' Add the label to the detail band.

    Return report
End Function

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
    ' Show the report's print preview.
    Dim printTool As New ReportPrintTool(CreateReport())
End Sub

Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button2.Click
    ' Open the report in an End-User Designer.
    Dim designTool As New ReportDesignTool(CreateReport())
End Sub


See Also