O'Reilly logo

ASP.NET in a Nutshell by Matthew MacDonald, G. Andrew Duthie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

DataGrid

Synopsis

The DataGrid control is, at its simplest, a data-bound list displayed in a table grid structure. It provides a rich set of functionality that makes it the most versatile data-bound control, including support for selection, editing, deleting, paging, and sorting.

Columns can be added to a DataGrid in two ways. First, if the AutoGenerateColumns property is True, a BoundColumn will be created for every column in the data source specified by DataSource. Alternatively, you can define columns by adding nested tags in the .aspx file. (If you mix both approaches, the automatically generated columns will always be added last.) Columns can be BoundColumn, ButtonColumn, EditCommandColumn, HyperLinkColumn, or TemplateColumn controls (each of which are described separately in this namespace). The order that the columns appear is determined by the order the column tags are listed in the .aspx, and you can manipulate them programmatically through the Columns collection. Note that this collection does not contain automatically generated columns—only ones that have defined templates.

The DataGrid has a number of properties that allow you to control its appearance. You can set TableItemStyle objects for various properties, including footers, headers (used automatically for column titles), and items. (The corresponding DataGrid properties end with the word “Style.”) You can also use the ShowHeader and ShowFooter properties to configure whether headers and footers will be displayed. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required