寻呼机刷新问题

发布于 2024-10-01 00:10:29 字数 157 浏览 1 评论 0原文

我有一个列表视图并将其与从数据库检索的项目绑定。我使用寻呼机导航到各个页面。但问题是,假设当前我位于第 25 页,并通过按 F5 或单击浏览器刷新按钮刷新页面,它会将我重定向到第 1 页。我的意思是第一页。但我希望刷新后它也应该在当前页面中,我的意思是在第 25 页中。我不明白为什么会发生这种情况。

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 getting why it is happening.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

满地尘埃落定 2024-10-08 00:10:29

最好添加带有当前页码的查询字符串。例如,假设您的页面是 a.aspx,只需传递一个像这样的查询字符串 a.aspx?pg=1.
在页面加载 if(Request.QueryString["pg"]!=null) 然后只显示第 1 页的记录。假设如果你想显示在第 25 页,那么 url 将是这样的: a.aspx?pg=25。因此,如果用户按 F5 刷新,它仍然会显示相同的数据。如果页面经历了回发(由于按钮单击事件或下拉列表所选索引更改等),则它由于查询字符串,也显示相同的记录。您还可以通过使用查询字符串中的另一个值将其重定向到同一页面来更改页码,例如:Response.Redirect("a.aspx?pg=26")

我想这会解决你的问题。

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.

话少心凉 2024-10-08 00:10:29

如果您以编程方式绑定页面加载事件,则会发生这种情况。您可以在用户更改页面时设置会话变量,并在页面加载事件中对其进行管理。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文