Online Book Reader

Home Category

Programming Microsoft ASP.NET 4 - Dino Esposito [232]

By Root 5366 0
data source.

Note

The GridView control provides a few properties specifically designed for accessibility. They are UseAccessibleHeader, Caption, CaptionAlign, and RowHeaderColumn. When you set RowHeaderColumn, all the column cells will be rendered with the default header style (boldface type). However, ShowHeader, HeaderStyle, and other header-related properties don’t affect the column indicated by RowHeaderColumn.

Table 10-6 details the style properties available on the GridView control.

Table 10-6. Style Properties of the GridView Control

Style

Description

AlternatingRowStyle

Defines the style properties for every other row in the table

EditRowStyle

Defines the style properties for the row being edited

FooterStyle

Defines the style properties for the grid’s footer

HeaderStyle

Defines the style properties for the grid’s header

EmptyDataRowStyle

Defines the style properties for the empty row, which is rendered when the GridView is bound to empty data sources

PagerStyle

Defines the style properties for the grid’s pager

RowStyle

Defines the style properties for the rows in the table

SelectedRowStyle

Defines the style properties for the currently selected row

Table 10-7 lists most of the properties that affect the appearance of the control, and Table 10-8 details the templating properties.

Table 10-7. Appearance Properties of the GridView Control

Property

Description

BackImageUrl

Indicates the URL to an image to display in the background

Caption

The text to render in the control’s caption

CaptionAlign

Alignment of the caption text

CellPadding

Indicates the amount of space (in pixels) between the contents of a cell and the border

CellSpacing

Indicates the amount of space (in pixels) between cells

EmptyDataText

Indicates the text to render in the control when it is bound to an empty data source

GridLines

Indicates the gridline style for the control

HorizontalAlign

Indicates the horizontal alignment of the control on the page

PagerSettings

References an object that lets you set the properties of the pager buttons

ShowFooter

Indicates whether the footer row is displayed

ShowHeader

Indicates whether the header row is displayed

The PagerSettings object groups together all the visual properties you can set on the pager. Many of these properties should sound familiar to DataGrid programmers. The PagerSettings class also adds some new properties to accommodate new predefined buttons (first and last pages), and it uses images instead of text in the links. (You need to figure out a trick to do the same with a DataGrid.)

Table 10-8. Templating Properties of the GridView Control

Template

Description

EmptyDataTemplate

Indicates the template content to be rendered when the control is bound to an empty source. This property takes precedence over EmptyDataText if both are set. If neither is set, the grid isn’t rendered if bound to an empty data source.

PagerTemplate

Indicates the template content to be rendered for the pager. This property overrides any settings you might have made through the PagerSettings property.

The final block of properties—the state properties—is shown in Table 10-9. State properties return information about the internal state of the control.

Table 10-9. State Properties

Property

Description

BottomPagerRow

Returns a GridViewRow object that represents the bottom pager of the grid.

Columns

Gets a collection of objects that represent the columns in the grid. The collection is always empty if columns are autogenerated.

DataKeyNames

Gets an array that contains the names of the primary key fields for the currently displayed items.

DataKeys

Gets a collection of DataKey objects that represent the values of the primary key fields set in DataKeyNames for the currently displayed records.

EditIndex

Gets and sets the 0-based index that identifies the row currently rendered in edit mode.

EnablePersistedSelection

Indicates whether the current selection is persisted across postbacks. (It

Return Main Page Previous Page Next Page

®Online Book Reader