Pager refresh issue
I am having a listview and binding it with items retrieving from database. I have used pager to navigate to various page. But problem is that suppose currently I am in page number 25 and refreshed the page by hitting F5 or clicking on the browser refresh button, it will redirect me to the page number 1. I mean to the first page. But I want after refreshing also it should be in the current page I mean in page 25. I am not gett开发者_如何学Cing why it is happening.
It is better to add a querystring with the current pagenumber. for eg Consider your page is a.aspx and just pass an querystring like this a.aspx?pg=1.
On the page load if(Request.QueryString["pg"]!=null)
then just display the records of page 1. Suppose if you want to show at 25th page then url will be like this: a.aspx?pg=25
.So if a user refreshing by F5 it will still displays the same data.If the page has undergone postback (due to button click event or dropdownlist selected index changed etc) it also displays the same record because of Querystring. You can also change the pagenumber by redirecting it to same page with another value in querystring Eg:Response.Redirect("a.aspx?pg=26")
.
I think this will solve your problem.
If you are programatically binding on the page load event, this will happen. You could set a session variable when the user changes page and manage this in the page load event too.
精彩评论