Loading the DataGrid Control with Data

In a previous chapter, you saw how to use the user-interface data components to bind a grid to a data source. You created OleDbDataAdapter and OleDbConnection objects and then used the menus to have the OleDbAdapter generate a typed DataSet for you. Although you can use these steps, you might want to bypass the overhead of the typed DataSet and bind the DataGrid to a simple DataSet that you create in code. As a matter of fact, you can bind a DataGrid to at least four different data objects:

  • DataSet

  • DataTable

  • DataView

  • DataReader

The only one of these that you haven't encountered yet is the DataView object. This object “wraps” itself around a DataTable and provides a sortable, filterable view of the data in the ...

Get ASP.NET Developer's JumpStart now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.