GRIDVIEW DATA CONTROL
The Gridview control is the successor to the DataGrid and extends it in a number of ways.
It provides more flexibility in displaying and working with data from your database in comparison with any other controls.
The Gridview control enables you to connect to a datasource and display data is tabular format
With this Gridview control, you could display an entire collection of data, easily add sorting and paging, and perform inline editing.
In addition to just displaying data, the Gridviewcan be used to edit and delete the displayed data as well.
The Gridview comes with a pair of complementary view controls:
1. DetailsView
2. FormView.
Its properties like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc. are implemented through style properites of <table> tag.
the GridView control reflected against the fields of the data records returned by SqlDataSource in order to dynamically generate the columns of the grid. You can also specify explicit column fields to display by adding DataControlFields objects to the GridView's Columns collection.
The Gridview control is the successor to the DataGrid and extends it in a number of ways.
It provides more flexibility in displaying and working with data from your database in comparison with any other controls.
The Gridview control enables you to connect to a datasource and display data is tabular format
With this Gridview control, you could display an entire collection of data, easily add sorting and paging, and perform inline editing.
In addition to just displaying data, the Gridviewcan be used to edit and delete the displayed data as well.
The Gridview comes with a pair of complementary view controls:
1. DetailsView
2. FormView.
Its properties like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc. are implemented through style properites of <table> tag.
the GridView control reflected against the fields of the data records returned by SqlDataSource in order to dynamically generate the columns of the grid. You can also specify explicit column fields to display by adding DataControlFields objects to the GridView's Columns collection.
Behavior Properties of the GridView Control | |
---|---|
AllowPaging | true/false. Indicate whether the control should support paging. |
AllowSorting | true/false. Indicate whether the control should support sorting. |
SortExpression | Gets the current sort expression (field name) that determines the order of the row. |
SortDirection | Gets the sorting direction of the column sorted currently (Ascending/Descending). |
DataSource | Gets or sets the data source object that contains the data to populate the control. |
DataSourceID | Indicate the bound data source control to use (Generally used when we are using SqlDataSource or AccessDataSource to bind the data, See 1st Grid example). |
AutoGenerateEditButton | true/false. Indicates whether a separate column should be added to edit the record. |
AutoGenerateDeleteButton | true/false. Indicates whether a separate column should be added to delete the record. |
AutoGenerateSelectButton | true/false. Indicate whether a separate column should be added to selecat a particular record. |
AutoGenerateColumns | true/false. Indicate whether columns are automatically created for each field of the data source. The default is true. |
Style Properties of the GridView Control | |
AlternatingRowStyle | Defines the style properties for every alternate row in the GridView. |
EditRowStyle | Defines the style properties for the row in EditView (When you click Edit button for a row, the row will appear in this style). |
RowStyle | Defines the style properties of the rows of the GridView. |
PagerStyle | Defines the style properties of Pager of the GridView. (If AllowPaging=true, the page number row appears in this style) |
EmptyDataRowStyle | Defines the style properties of the empty row, which appears if there is no records in the data source. |
HeaderStyle | Defines the style properties of the header of the GridView. (The column header appears in this style.) |
FooterStyle | Defines the style properties of the footer of GridView. |
Appearance Properties of the GridView Control | |
CellPadding | Indicates the space in pixel between the cells and the border of the GridView. |
CellSpacing | Indicates the space in pixel between cells. |
GridLines | Both/Horizontal/Vertical/None. Indicates whether GrdiLines should appear or not, if yes Horizontal, Vertical or Both. |
HorizontalAlign | Indicates the horizontal align of the GridView. |
EmptyDataText | Indicates the text to appear when there is no record in the data source. |
ShowFooter | Indicates whether the footer should appear or not. |
ShowHeader | Indicates whether the header should appear or not. (The column name of the GridView) |
BackImageUrl | Indicates the location of the image that should display as a background of the GridView. |
Caption | Gets or sets the caption of the GridView. |
CaptionAlign | left/center/right. Gets or sets the horizontal position of the GridView caption. |
State Properties of GridView Control | |
Columns | Gets the collection of objects that represent the columns in the GridView. |
EditIndex | Gets or sets the 0-based index that identifies the row currently to be edited. |
FooterRow | Returns a GridViewRow object that represents the footer of the GridView. |
HeaderRow | Returns a GridViewRow object that represents the header of the GridView. |
PageCount | Gets the number of the pages required to display the reocrds of the data source. |
PageIndex | Gets or sets the 0-based page index. |
PageIndex | Gets or sets the number of records to display in one page of GridView. |
Rows | Gets a collection of GridViewRow objects that represents the currently displayed rows in the GridView. |
DataKeyNames | Gets an array that contains the names of the primary key field of the currently displayed rows in the GridView. |
DataKeys | Gets a collection of DataKey objects that represent the value of the primary key fields set in DataKeyNames property of the GridView. |
Events associated with GridView Control | |
PageIndexChanging, PageIndexChanged | Both events occur when the page link is clicked. They fire before and after GridView handles the paging operation respectively. |
RowCancelingEdit | Fires when Cancel button is clicked in Edit mode of GridView. |
RowCommand | Fires when a button is clicked on any row of GridView. |
RowCreated | Fires when a new row is created in GridView. |
RowDataBound | Fires when row is bound to the data in GridView. |
RowDeleting,RowDeleted | Both events fires when Delete button of a row is clicked. They fire before and after GridView handles deleting operaton of the row respectively. |
RowEditing | Fires when a Edit button of a row is clicked but before the GridView hanldes the Edit operation. |
RowUpdating, RowUpdated | Both events fire when a update button of a row is clicked. They fire before and after GridView control update operation respectively. |
Sorting, Sorted | Both events fire when column header link is clicked. They fire before and after the GridView handler the Sort operation respectively. |
0 comments:
Post a Comment