Creating a Data Table in Code

The DataTableCode example on the CD-ROM creates a data table from scratch, uses it to create a dataset, and then binds that dataset to a data grid, as you see in Figure 22.2. This example will show us how to create not only a data table from scratch, but also an entire dataset.

Figure 22.2: Creating a data table in code.

Let's see how this works in code. When the user clicks the "Create and bind new data table" button you see in Figure 22.2, the code starts by creating a data table named Employees, like this: