GridView Class

Displays the values of a data source in a table where each column represents a field and each row represents a record. The GridView control enables you to select, sort, and edit these items.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web 
(in System.Web.dll)
The GridView control is used to display the values of a data source in a table. Each column represents a field, while each row represents a record. The GridView control supports the following features:
·         Binding to data source controls, such as SqlDataSource.
·         Built-in sort capabilities.
·         Built-in update and delete capabilities.
·         Built-in paging capabilities.
·         Built-in row selection capabilities.
·         Programmatic access to the GridView object model to dynamically set properties, handle events, and so on.
·         Multiple key fields.
·         Multiple data fields for the hyperlink columns.
·         Customizable appearance through themes and styles.

Column Fields 

Each column in the GridView control is represented by a DataControlField object. By default, the AutoGenerateColumns property is set totrue, which creates an AutoGeneratedField object for each field in the data source. Each field is then rendered as a column in the GridViewcontrol in the order that each field appears in the data source.


Column field type
Description
BoundField
Displays the value of a field in a data source. This is the default column type of the GridView control.
ButtonField
Displays a command button for each item in the GridView control. This enables you to create a column of custom button controls, such as the Add or the Remove button.
CheckBoxField
Displays a check box for each item in the GridView control. This column field type is commonly used to display fields with a Boolean value.
CommandField
Displays predefined command buttons to perform select, edit, or delete operations.
HyperLinkField
Displays the value of a field in a data source as a hyperlink. This column field type enables you to bind a second field to the hyperlink's URL.
ImageField
Displays an image for each item in the GridView control.
TemplateField
Displays user-defined content for each item in the GridView control according to a specified template. This column field type enables you to create a custom column field.









You can also manually control which column fields appear in the GridView control by setting the AutoGenerateColumns property to falseand then defining your own column field collection. Different column field types determine the behavior of the columns in the control. The following table lists the different column field types that can be used.
To define a column field collection declaratively, first add opening and closing <Columns> tags between the opening and closing tags of the GridView control. Next, list the column fields that you want to include between the opening and closing <Columns> tags. The columns specified are added to the Columns collection in the order listed. The Columns collection stores all the column fields in the control and enables you to programmatically manage the column fields in the GridView control.

0 Responses to “GridView Class”

Post a Comment

Labels

Topics