i

ASP.Net A Complete Guide

GridView

It used to display the values of data in a tabular format where every column represents a field, and every row represents a record. This control allows us to select, sort, and edit the records.

We can use one of the below ways to bind the GridView control to the data source:

We can set the DataSourceID property of the GridView control to the ID value of the data source control. It automatically binds the specific data source.

For binding the data source for those who implement the System.Collections.IEnumerable interface, in code, needs to set the DataSource property of the GridView control to data source & call the DataBind method.

In the image below, We will see a "GridView" control. You can add that on a web page by just doing the drag and drop operation.

In the image below, wecan see the design part.

Syntax:

The DataGrid supports two kinds of paging one is the default, and another one is custom paging. In default paging, the complete one record gets fetched from the database. The DataGrid selects records from the complete set of data, as per the page size, to display it in DataGrid.

 In custom paging, developers require to write the code logic for retrieving the records from the entire records to display on each page. Custom paging provides better performance as compared with the default paging. Set the AllowPaging property of the GridView to true for enabling the default paging property.