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 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.