Skip to main content

GridControl.DataSource Property

Gets or sets the grid control’s data source.

Namespace: DevExpress.XtraGrid

Assembly: DevExpress.XtraGrid.v23.2.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation


public virtual object DataSource { get; set; }

Property Value

Type Default Description
Object null

An object representing the grid control’s data source.


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.

gridControl1.DataSource = xmlDataSet.Tables["product"];

The following code snippets (auto-collected from DevExpress Examples) contain references to the DataSource property.


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