Click here to Skip to main content
15,919,931 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i have gridview with paging when i refresh the page, i want to remain it on same page index of gridview. presently it goes to first page index of gridview
Posted
Updated 27-Nov-11 21:48pm
v3

Put the CurrentPageIndex in session and after page postback set the pageindex again.

C#
protected void Page_Load(object sender, EventArgs e)
 {     
if(!IsPostBack)
     { 
        Gridview1.PageIndex =convert.ToInt32(Session["PageIndex"])
    }
 } 
 
Share this answer
 
Try this...

On page every data bind:
C#
Session["index"] = GridView1.PageIndex;


On page load:
C#
if(!Page.IsPostBack)
{
   //bind gridview
   GridView1.PageIndex = Convert.ToInt32(Session["index"]);
}


Please mark as answer if this solved your problem

Regards,
Eduard
 
Share this answer
 
v2
do not use clear function for the particular gridview...
 
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