Sorting , Paging and AutoGenerateColumns
The GridView control provides many built-in capabilities that allow the user to sort, update, delete, select, and page through items in the control.
In this article I have used SQL SERVER database for sample data.
Before you start to generate GridView in your asp file, you should create a ConnectionString in your web.Config File. Double click the web.config file on the right hand side of the Visual Studio and add the following connectionstring code in that file.
Girdview.aspx
In this article I have used SQL SERVER database for sample data.
Create table tblRecord ( Id int primary key, Name varchar(200),Branch varchar(50) ) --Insert some record
Before you start to generate GridView in your asp file, you should create a ConnectionString in your web.Config File. Double click the web.config file on the right hand side of the Visual Studio and add the following connectionstring code in that file.
Web.Config File
Each column in the GridView control is represented by a DataControlField object.
By default, the AutoGenerateColumns property is set to true, You can also manually control which column fields appear in the GridView control by setting the AutoGenerateColumns property to false .
AutoGenerateColumns="false"
Sorting allows the user to sort the items in the GridView control with respect to a specific column by clicking on the column's header.
To enable sorting, set the AllowSorting property to true.
AllowSorting="True"
Instead of displaying all the records in the data source at the same time, the GridView control can automatically break the records up into pages. To enable paging, set the AllowPaging property to true.
AllowPaging="True"
Also we can set how many rows we want to see in a page. PageSize="3"
The following ASP.NET program shows how to enable sorting and paging in a GridView with a custom defined column fields.
By default, the AutoGenerateColumns property is set to true, You can also manually control which column fields appear in the GridView control by setting the AutoGenerateColumns property to false .
AutoGenerateColumns="false"
Sorting allows the user to sort the items in the GridView control with respect to a specific column by clicking on the column's header.
To enable sorting, set the AllowSorting property to true.
AllowSorting="True"
Instead of displaying all the records in the data source at the same time, the GridView control can automatically break the records up into pages. To enable paging, set the AllowPaging property to true.
AllowPaging="True"
Also we can set how many rows we want to see in a page. PageSize="3"
The following ASP.NET program shows how to enable sorting and paging in a GridView with a custom defined column fields.
Girdview.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Girdview.aspx.cs" Inherits="Girdview" %>