JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

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:

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    Dim Table1 As DataTable
    Table1 = New DataTable("Employees")

The next step is to stock the data table with columns, and we'll do that in the next topic.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor