Now that you have a working data source control on your web page, let’s hook it up to a control to display the data you’ve retrieved. You will use a
GridView control, the workhorse data grid in ASP.NET.
GridView is derived from the
BaseDataBoundControl class, along with many other controls, such as the
FormView controls, the members of the
ListControl class, such as
RadioButtonList, and so on, and composite controls, such as the password controls, wizards, and so on. The
DataList controls derive from
BaseDataBoundControl. (Refer to Figure 3-3 in Chapter 3 for a schematic diagram of the class structure of
System.Web.UI.Control.) Though they derive from different base classes, the
GridView and the
DataList (described later in this chapter) share many of the same properties.
Users of ASP.NET Version 1.x, will probably now use a
GridView rather than a
GridView does all that the
DataGrid does and much more, including providing easier paging and sorting. The
DataGrid is fully compatible with Version 2.0, with no requirement to modify existing projects to run under the new version.
Many of the most commonly used properties of the
GridView control not inherited from the control or
WebControl classes are listed in Table 9-1. Many of these properties are described and used in subsequent sections of this chapter.
Table 9-1. GridView properties not inherited from WebControl