TDataGridColumn serves as the base class for the different column types of the TDataGrid control. TDataGridColumn defines the properties and methods that are common to all column types. In particular, it initializes header and footer cells according to HeaderText, HeaderStyle, FooterText, and FooterStyle. If HeaderImageUrl is specified, the image will be displayed instead in the header cell. The ItemStyle is applied to non-header and -footer items.
When the datagrid enables sorting, if the SortExpression is not empty, the header cell will display a button (linkbutton or imagebutton) that will bubble sort command event to the datagrid.
The framework provides the following TDataGridColumn descendant classes,
TBoundColumn, associated with a specific field in datasource and displays the corresponding data.
TButtonColumn, displaying generic command buttons that may be bound to specific field in datasource.
THyperLinkColumn, displaying a hyperlink that may be boudn to specific field in datasource.
TTemplateColumn, displaying content based on templates.
To create your own column class, simply override initializeCell() method, which is the major logic for managing the data and presentation of cells in the column.
Namespace: System.Web.UI.WebControls
Properties
ItemStyle, string, stored in viewstate
Gets or sets the css style for item cell
HeaderText, string, stored in viewstate
Gets or sets the text to be displayed in header cell
HeaderStyle, string, stored in viewstate
Gets or sets the css style for header cell
HeaderImageUrl, string, stored in viewstate
Gets or sets the url to the image that will be displayed in header cell
FooterText, string, stored in viewstate
Gets or sets the text to be displayed in footer cell
FooterStyle, string, stored in viewstate
Gets or sets the css style for footer cell
SortExpression, string, stored in viewstate
Gets or sets the sort expression that will be passed to OnSortCommand event parameter.
Initializes the specified cell to its initial values.
The default implementation sets the content of header and footer cells and the style of other kinds of cell. If sorting is enabled by the grid and sort expression is specified in the column, the header cell will show a link/image button. Otherwise, the header/footer cell will only show static text/image. This method can be overriden to provide customized intialization to column cells.