GridControl.DataSource Property

Gets or sets the grid control's data source.

Namespace: DevExpress.XtraGrid

Assembly: DevExpress.XtraGrid.v20.1.dll

Declaration

[DefaultValue(null)]
[DXCategory("Data")]
public virtual object DataSource { get; set; }
<DefaultValue(Nothing)>
<DXCategory("Data")>
Public Overridable Property DataSource As Object

Property Value

Type Default Description
Object

null

An object representing the grid control's data source.

Remarks

Refer to the Data Binding and Master-Detail Relationships topics for information on which objects can be assigned to the DataSource property.

After the DataSource property is set to null, the ColumnView.FocusedRowHandle of the GridControl.MainView is set to GridControl.InvalidRowHandle. After a new data source is assigned to the DataSource property, the ColumnView.FocusedRowHandle is set to 0, to refer to the first data record.

The code sample below illustrates how to bind the GridControl to XML data.


xmlDataSet.ReadXml(@".\products.xml");
gridControl1.DataSource = xmlDataSet.Tables["product"];
See Also