Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to allow paging for the gridview. I have set PagerSettings properties to the gridview. Also i have created event of OnPageIndexChanging...

Here is my code..,

C#
protected void GrdATGmailContact_PageIndexChanging(object sender,GridViewPageEventArgs e)
{
    GrdATGmailContact.PageIndex = e.NewPageIndex;
    GrdATGmailContact.DataBind();
}


But when i click on next button. It wont display grid. What should I do to correct this error??
Posted
Updated 17-Dec-12 19:25pm
v2

ASP.NET Enhanced Grid View with Custom Pagination[^]
paging in asp.net gridview[^]
Pagination Class for ASP.NET MVC[^]

Pagination In Grid veiw Without passing paging parameters in Stored Procedure In ASP.net[^]

Quote:
Set the Gridview's properties AllowPaging="true" and pagesize="10"

or
Quote:
set gridview property AllowPaging="true" ;
and In page index changing event
C#
protected void GrdATGmailContact_PageIndexChanging(object sender, GridViewPageEventArgs e)
       {
            GrdATGmailContact.PageIndex = e.NewPageIndex;
            FillGrid();//method to bind grid
        }




hope it helped.
 
Share this answer
 
v2
Comments
AshishChaudha 18-Dec-12 1:30am    
Perfect!!my !5+
Abhishek Pant 18-Dec-12 1:55am    
thanks
Pagination for gird view[^]

Check this link
 
Share this answer
 
Effective Paging with GridView Control in ASP.NET[^]

Set allowpaging property of grid view to true
In pageindex changing event write the following code
C#
gridview1.pageindex=e.newpageindex;
gridview1.databind();
 
Share this answer
 
You have to set Gridview's Property Allowpaging=true

In code you have written a code in pageindexchanging.

C#
gridview1.pageindex=e.newpageindex;
gridview1.databind();


In above code you are missing the datasource for Gridview, or you can call the same function which you have used to fill the Gridview.



C#
gridview1.pageindex=e.newpageindex;
//Code for fill datatable or dataset
gridview1.datasource=dt;
gridview1.databind();



Thanks
 
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