Using the DataTable Object

The DataTable object represents an in-memory database table. You can add rows to a DataTable with a SqlDataAdapter, with a SqlDataReader, with an XML file, or programmatically. For example, the page in Listing 19.28 builds a new DataTable programmatically. The contents of the DataTable then display in a GridView control (see Figure 19.14).

Figure 19.14. Displaying a DataTable that was built programmatically.

image

Listing 19.28. ShowDataTableProgram.aspx

images

In Listing 19.28, a DataTable with the following three columns is ...

Get ASP.NET 4 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.