The DataTable: Filtering, Adding, Editing, Sorting, and Deleting DataRows

Because we believe it is important to develop a good fundamental understanding of new technology, we thought we should start this chapter with code illustrating how to create a DataTable and DataSet from “scratch.” We are going to dynamically build the DataSet, DataTable, DataColumn, and DataRow objects and then bind to a DataGrid (Listing 11.1).

Listing 11.1. Constructing a DataTable
 [VisualBasic.NET] 01: <%@ import namespace="System.Data" %> 02: 03: <script language="vb" runat="server"> 04: 05: sub Page_Load(sender as Object, e as EventArgs) 06: 07: dim DS as new DataSet() 08: dim DC as DataColumn 09: dim DR as DataRow 10: 11: dim DT as new DataTable("Counters") 12: ...

Get Programming Data-Driven Web Applications with ASP.NET 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.