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.v20.1.dll

Declaration

[DefaultValue("")]
[DXCategory("Data")]
public virtual string DataMember { get; set; }
<DefaultValue("")>
<DXCategory("Data")>
Public Overridable Property DataMember As String

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("http://northwind.servicestack.net/customers.json"));

    jsonDataSource.Fill();
    return jsonDataSource;
}
See Also