Posted by : Anwar Hossain
Category : How to use grid view in c#

How to create grid view paging in using c#

Dear Viewers I will show how to paging grid view data in c#. Sometimes a big amount of data is required to load from database for displaying data using grid view control .In this case we can use grid view PageIndexChanging event . At first we need to double click on PageIndexChanging event and need to true allowpaing properties and define the PageSize properties to display what amount of data to be displayed at a time during pagechanging .

Grid view paging Example in c #.


<head runat="server">
  <title>Grid view Paging</title>
  <form id="form1" runat="server">
  <asp:GridView ID="gvStudentList" AutoGenerateColumns="false" CellPadding="5"
  runat="server" AllowPaging="True"
  onpageindexchanging="gvStudentList_PageIndexChanging" PageSize="6"
  <asp:BoundField HeaderText="Student Name" DataField="_StudentName" ItemStyle-HorizontalAlign="Center" />
  <asp:BoundField HeaderText="Student Phone" DataField="_StudentPhone" ItemStyle-HorizontalAlign="Center" />
  <asp:BoundField HeaderText="Adress " DataField="_StudentAddress" ItemStyle-HorizontalAlign="Center" />
  <asp:BoundField HeaderText="Due Payment" DataField="_DuePayment" ItemStyle-HorizontalAlign="Center" />
  <HeaderStyle BackColor="#0066FF" Font-Bold="true" ForeColor="White" />
  <FooterStyle BackColor="#3366CC" />


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class TestDesign_GridViewPagingExample : System.Web.UI.Page
  protected void Page_Load(object sender, EventArgs e)
  if (!IsPostBack)
  //Create temporarydata but real time data will be loaded form database
  private void AllStudentList()
  List<Student> StudentList = new List<Student>();
  StudentList.Add(new Student("Iqbal Hossain", "01916751804", "Noakhali", 50000));
  StudentList.Add(new Student("Jabed Hossain", "01916751805", "Lakmipur", 70000));
  StudentList.Add(new Student("Fazlul Goni Roman", "01916751806", "Chandpur", 80000));
  StudentList.Add(new Student("Prince Hossain", "01916751807", "Rangpur", 90000));
  StudentList.Add(new Student("Mr Khorsed Alam", "01916751864", "Narayangonj", 50000));
  StudentList.Add(new Student("Sumay Akter", "01916751804", "Sirajgonj", 50000));
  StudentList.Add(new Student("Siful Islam", "01916751808", "Dhaka", 1000000));
  StudentList.Add(new Student("Abul Kasem", "01916751807", "Rangpur", 90000));
  StudentList.Add(new Student("Jamala Hossain", "01916751964", "Chittagong", 50000));
  StudentList.Add(new Student("Helal Ahmed", "01916751806", "Jessore", 50000));
  StudentList.Add(new Student("Nasim ul Goni", "01916751808", "Dinajpur", 1000000));
  gvStudentList.DataSource = StudentList;
  //Create student class for temporarydata
  public class Student
  public Student(string StudentName, string StudentPhone, string StudentAddress, decimal DuePayment)
  _StudentName = StudentName;
  _StudentPhone = StudentPhone;
  _StudentAddress = StudentAddress;
  _DuePayment = DuePayment;
  public string _StudentName { get; set; }
  public string _StudentPhone { get; set; }
  public string _StudentAddress { get; set; }
  public decimal _DuePayment { get; set; }

  //PageIndexChanging Event

  protected void gvStudentList_PageIndexChanging(object sender, GridViewPageEventArgs e)
  gvStudentList.PageIndex = e.NewPageIndex;

Out Put

Realted Article Headline

Gridview datetime format example in ASP.Net c#
Displaying total column value in the Gridview Footer using c#.
How to create grid view paging in using c#
How to bind Multi-Dimensional Arrays Data to gird view in using C#
How to bind Two-Dimensional Arrays Data to gird view in using C#
How to bind Single-Dimensional Arrays Data to gird view in using C#
how to export gridview data to pdf in c#
how to export gridview data to word in using c#
how to export gridview data to excel in c#
How to delete row from grid view showing confirmation JavaScript using c#
How to delete data from grid view using row deleting event in c#
How to bind data into gridview using code behind in c#
How to scroll gird view overflow data in c#
How to Bind data into grid view control using c#

Article Category

How to create control dynamically
Learn HTML for beginner
DataList example in C Sharp
Mail sending in c#
State Management in ASP C #
Basic sql tutorial for Beginner
DataTable example in ASP.Net C#
How to use LINQ in ASP.NET C# c # basic tutorial
How to use ajax toolkit in C#
How to use different types of validation control using c#
How to use grid view in c#
Protected by Copyscape Online Plagiarism Detection