Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server
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 14-Jul-12 23:04pm
Comments
OriginalGriff at 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 J at 15-Jul-12 5:24am
   
share your code/project please!!!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

<asp:gridview id="Gridview1" runat="server" autogeneratecolumns="False" allowpaging="True" onpageindexchanging="Gridview1_PageIndexChanging" xmlns:asp="#unknown"></asp:gridview>
 
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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Sandeep Mewara at 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)

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 265
2 CPallini 235
3 Sergey Alexandrovich Kryukov 229
4 Maciej Los 190
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 27 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100