Click here to Skip to main content
15,904,494 members
Please Sign up or sign in to vote.
2.13/5 (7 votes)
See more:
how to enable paging for gridview in asp.net using vb.net code
Posted
Comments
King Fisher 31-Jan-14 7:22am    
got the answer?

GridView Custom Paging[^]

Also Try this one.....:)

 
Share this answer
 
C#
protected void grvDetails_PageIndexChanging(object sender, GridViewPageEventArgs e)
       {
           grvDetails.PageIndex = e.NewPageIndex;
           bindGrid();
       }
 
Share this answer
 
select gridview ->goto properties window ->click on events button

double click on pageindexchanging event

and set

Allowpaging=true for gridview

in pageindex changing event write the following code
gridview1.pageindex=e.newpageindex;
//gridbindingcode
gridview1.databind();
 
Share this answer
 
Comments
v.sdivya 1-Oct-11 10:35am    
thank you...I tried with this coding, but next page is not getting loaded...I have used a single gridview for viewing details date wise(using calendar) and also for viewing fully.how to use paging here?
RAKESH CHAUBEY 2-Nov-12 14:02pm    
Plz Check allow paging is true or not .And Just for one time set page size =2
Set allowpaging property of grid view to true

and set pagesize property to no of records you want in each page.

in pageindex changing event write the following code

gridview1.pageindex=e.newpageindex;

gridview1.databind();
 
Share this answer
 
v3
Comments
v.sdivya 1-Oct-11 10:34am    
thank you...I tried with this coding, but next page is not getting loaded...I have used a single gridview for viewing details date wise(using calendar) and also for viewing fully.how to use paging here?
v.sdivya 2-Oct-11 16:00pm    
Please reply .
RAKESH CHAUBEY 2-Nov-12 14:01pm    
grvDetails.PageIndex = e.NewPageIndex;
bindGrid();
In pge index changing event write the following code

C#
protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
   gridView.PageIndex = e.NewPageIndex;
   gridView.DataBind();
}
 
Share this answer
 
v2
Comments
v.sdivya 1-Oct-11 10:35am    
thank you...I tried with this coding, but next page is not getting loaded...I have used a single gridview for viewing details date wise(using calendar) and also for viewing fully.how to use paging here?
[no name] 6-Nov-13 4:16am    
<asp:GridView AllowPaging="True|False" />


<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>GridView AllowPaging Example</title>
</head>
<body>
<form id="form1" runat="server">

GridView AllowPaging Example



<asp:gridview id="CustomersGridView"
datasourceid="CustomersSource"
autogeneratecolumns="true"
emptydatatext="No data available."
allowpaging="true"
runat="server">

<pagersettings mode="Numeric"
position="Bottom"
pagebuttoncount="10"/>

<pagerstyle backcolor="LightBlue"
height="30px"
verticalalign="Bottom"
horizontalalign="Center"/>



<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:sqldatasource id="CustomersSource"
selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server"/>

</form>
</body>
</html>
 
Share this answer
 
XML
<asp:GridView ID="grd_EmployeeList" runat="server" AutoGenerateColumns="False" 
BackColor="White"
DataKeyNames="fEmpID" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="0px" CellPadding="3" CssClass="controlsFontStyle" ForeColor="Black" HeaderStyle-Height="22px" Height="22px" RowStyle-Height="22px" OnSelectedIndexChanging="SelectedIndexChanging_Click" OnRowCommand="OnRowCommand_Click" ShowHeaderWhenEmpty="True" Width="100%" PageSize="15" AllowPaging="True" EnableSortingAndPagingCallbacks="true" onpageindexchanging=" grd_EmployeeList_PageIndexChanging">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900