Pageable Data Grids

Column Types

A DataGrid control is formed by data bound columns. The control has the ability to automatically generate columns that are based on the structure of the data source. Auto-generation is the default behavior, but you can manipulate that behavior by using a Boolean property named AutoGenerateColumns. Set the property to false when you want the control to display only the columns you explicitly add to the Columns collection. Set it to true (the default) when you want the control to add as many columns as is required by the data source. The default algorithm for column generation creates simple data bound columns that use literal controls to display the contents of the corresponding data source fields. The DataGrid control supports additional column types that can render the column data so that it performs an action when clicked. The column types are explained in Table 2-2. Each is derived from the DataGridColumn class.

Table 2-2 Column Types Supported by the DataGrid Control

Column Type

Description

BoundColumn

Displays a column that is bound to a field in a data source. It displays each item in the field as plain text.

ButtonColumn

Displays a command button for each item in the column. The text of the button can be data bound. The command name of the button must be common to all items in the column. When the value for the command name is Select, clicking the column button automatically selects the row.

EditCommandColumn

Displays a button column that is automatically associated with the Edit command. This class receives special support from the DataGrid control, which is manifested as a redrawing of the clicked row using a template. (I ll talk more about this in Chapter 4.)

HyperLinkColumn

Displays the contents of each item in the column as a link. The link text can be bound to a field in the data source, or it can be static text. Also, the target URL can be data bound. Clicking a link column causes the browser to jump to the specified URL. This column class supports target frames.

TemplateColumn

Displays each item in the column according to a specified template, allowing you to provide custom controls in the column. (I ll talk more about this in Chapter 3.)



Building Web Solutions with ASP. NET and ADO. NET
Building Web Solutions with ASP.Net and ADO.NET
ISBN: 0735615780
EAN: 2147483647
Year: 2002
Pages: 75
Authors: Dino Esposito

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net