Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Problem with Paging in Gridview in asp.net
==========================================

Hi Friends, This is Rahman.

am working on asp.net c#, sqlserver 2005.

am facing problem with Gridview paging.

I have a Gridview on my WEBPAGE. and filled data in it with Paging.

I have thousands of records in gridview. i used to do Paging for it.

1,2,3,4,5...........................500.

when i click on pages 2,3,4... and when i click back to the 1st page it doesnot comes to first page.

this is the problem am facing. Please help me for better solution.

Special thanks.
Posted
Comments
OriginalGriff 15-Jul-12 4:26am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
"It does not come to first page" is not very helpful. Where does it go? Nowhere? Last page? Whst code are you using to page it?
Use the "Improve question" widget to edit your question and provide better information.
Santhosh Kumar Jayaraman 15-Jul-12 5:24am    
share your code/project please!!!

ASP.NET
<asp:gridview id="Gridview1" runat="server" autogeneratecolumns="False" allowpaging="True" onpageindexchanging="Gridview1_PageIndexChanging" xmlns:asp="#unknown"></asp:gridview>


C#
static DataTable dt;//Globally in class

 Gridview1.DataSource = dt;
            Gridview1.DataBind();


protected void Gridview1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        Gridview1.PageIndex = e.NewPageIndex;
        Gridview1.DataSource = dt;
        Gridview1.Page.DataBind();
    }


This will help you properly
 
Share this answer
 
yes sir,

I used gridview Page Index changing Event, and set allow paging properties to true.


protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{

GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();

}


Please give me a good solution.
 
Share this answer
 
Comments
Sandeep Mewara 16-Jul-12 2:06am    
This is not an answer. Please use 'Have a Question or Comment' link to respond to an answer. Use Improve Question link to edit/update your question.

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