How do you bind data to a DevExpress grid, and how do you keep it fast with large datasets?

DevExpress Data Grid Advanced 3–5 Yrs5+ Yrs Scenario 2 min read

Quick Answer

Bind by setting gridControl.DataSource to a list, BindingList<T>, DataTable or a server-mode source. For large data, don't load everything into memory — use server mode (WinForms: LinqServerModeSource / EntityServerModeSource; web: bind to IQueryable) so paging, sorting, filtering and grouping are pushed to the database and only the visible rows are fetched.

For normal amounts of data I just set DataSource to a BindingList or a DataTable and call RefreshDataSource when I swap the contents. The real question is large data, and the answer is server mode — EntityServerModeSource over an EF IQueryable, or binding an IQueryable directly on the web. That way when the user sorts, filters, groups or scrolls, the grid turns it into a SQL query and only pulls the rows on screen, instead of loading a million rows into memory. The cost is a round trip per operation and being limited to translatable queries. I also add instant feedback mode so loading happens off the UI thread, and I keep the per-cell events like RowCellStyle cheap because they run for every visible cell on every repaint.

Standard binding — assign a collection to DataSource. Use BindingList<T> or BindingSource so the grid sees add/remove; call RefreshDataSource() after replacing the collection contents.

Large datasets — the interview point:

  • Server mode — the grid translates its operations into queries. EntityServerModeSource wraps an EF IQueryable; the grid never materialises more than a page. Trade-off: every operation is a round trip, and you're limited to what the provider can translate.
  • Instant feedback mode — server mode plus a background thread, so the UI stays responsive while data loads.
  • Virtual mode — you supply rows on demand via events for a custom source.

Other performance tips: turn off features you don't need (auto-filter row, footer summaries that force full scans), avoid heavy work in RowCellStyle/CustomColumnDisplayText (they fire per visible cell, repeatedly), and load only the columns you display.