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

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

Declaration

[SRCategory(ReportStringId.CatData)]
[DefaultValue("")]
public string DataMember { get; set; }
<SRCategory(ReportStringId.CatData)>
<DefaultValue("")>
Public Property DataMember As String

Property Value

Type Default Description
String

String.Empty

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

Remarks

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.

Note

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.

Examples

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. 
    ds.Queries.Add(query)

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

    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
    report.Bands.Add(detailBand)

    ' 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")
    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) Handles button1.Click
    ' Show the report's print preview.
    Dim printTool As New ReportPrintTool(CreateReport())
    printTool.ShowPreview()
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())
    designTool.ShowRibbonDesignerDialog()
End Sub
See Also