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,LinqDatasource etc.
- Built-in sort capabilities in GridView.
- 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.
- We can provide appearance through themes and styles.
Each column in the GridView control is represented by a DataControlField object. By default, the AutoGenerateColumns property is set to true. We can set the column field manually then following table lists the different column field types that can be used.
Column field Type
Description, BoundField, ButtonField, CheckBoxField, CommandField, HyperLinkField, ImageField and TemplateField.
When we set the column manually then remove the auto column generates checkbox.
Binding to Data
The GridView control can be bound to a data source control (such as SqlDataSource, ObjectDataSource, and so on).After binding the data we can easily performed the action such as update data, delete data, sort data, paging data etc.
Customizing the user interface
You can customize the appearance of the GridView control by setting the style properties for the different parts of the control. The following table lists the different style properties.
Description, AlternatingRowStyle, EditRowStyle, EmptyDataRow Style, FooterStyle, HeaderStyle, PagerStyle, RowStyle, SelectedRowStyle.
The GridView control provides several events that you can program against. This enables you to run a custom routine whenever an event occurs. The following table lists the events that are supported by the GridView control.
Description, PageIndexChanging, PageIndexChanged, RowCancelingEdit, RowCommand, RowCreated, RowDataBound, RowDeleted, RowDeleting, RowEditing, RowUpdated, RowUpdating, ,Sorted, Sorting SelectIndexChanged , SelectIndexChanging.