Skip to main content

GridControl.DataMember Property

Gets or sets a sub-list of the data source (GridControl.DataSource) whose data is supplied for the grid control’s main View.

Namespace: DevExpress.XtraGrid

Assembly: DevExpress.XtraGrid.v24.2.dll

Declaration

[DefaultValue("")]
[DXCategory("Data")]
public virtual string DataMember { get; set; }

Property Value

Type Default Description
String String.Empty

A string value representing the data source member.

Remarks

This property is useful when binding to a data source containing several lists, tables or data relationships. In this case, set the GridControl.DataSource property to the aggregated data source and set the DataMember property to the name that identifies the desired table/list/data relationship. The specified data is supplied for the grid control’s main View (GridControl.MainView).

Example

The code below binds the Data Grid to sample data stored in JSON format. This source contains the “root” element that includes two data tables: “Customers”, and “ResponseStatus”. The Grid displays data from the “Customers” table due to the DataMember property value.

private void Form1_Load(object sender, EventArgs e)
{
    gridControl1.DataMember = "Customers";
    gridControl1.DataSource = CreateDataSourceFromWeb();
}

private JsonDataSource CreateDataSourceFromWeb()
{
    var jsonDataSource = new JsonDataSource();
    //Specify the data source location 
    jsonDataSource.JsonSource = new UriJsonSource(new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.jso"));

    jsonDataSource.Fill();
    return jsonDataSource;
}

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.

See Also