ASP.NET的下一个/上一个按钮以显示表单中的单行 [英] ASP.NET next/previous buttons to display single row in a form

查看:74
本文介绍了ASP.NET的下一个/上一个按钮以显示表单中的单行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找在ASP.NET中实现此目标的最佳方法.

I'm looking for the best way to implement this in ASP.NET.

在页面上,用户可以选择使用下一个和上一个按钮通过订阅号翻页".

On the page, the user has an option to "page" through subscription numbers with next and previous buttons.

当用户单击下一个/上一个"按钮时,页面将回发(部分,AJAX),并且订阅详细信息以表格形式显示.一次只显示一行.

When the user clicks the next/previous buttons, the page is posted back (partial, AJAX) and the subscription details is displayed in a form. There is only one row displayed at a time.

大约有10,000个订阅号,因此,如果我们可以避免在每次回发中都加载所有订阅号,那么我们宁愿这样做.

There is like 10,000 subscription numbers, so if we can avoid loading all the subscription numbers on every postback, we would prefer that.

以某种方式我需要一个计数器来跟踪总物料和当前位置,不是吗?如果是这样,您将如何存储它们以便它们在回发时持续存在?

Somehow I need a counter to keep track of total items and the current position, no? If thats so, how would you store them so they persist on postback?

先谢谢了.非常感谢您的帮助.

Thanks in advance. Help is much appreciated.

推荐答案

您可以在页面上创建属性变量,并将值存储在页面的ViewState中.这是一个示例:

You can create property variables on the page and store the values in the Page's ViewState. Here's an example:

public int CurrentPosition
{
  get{return (int)(ViewState["CurrentPosition"] ?? 0);}
  set{ViewState["CurrentPosition"] = value;}
}

在此示例中,在回发之间(无论是全部还是部分),保存在CurrentPosition属性中的值将保持不变.

In this example, between postbacks, whether full or partial, the value saved in the CurrentPosition property will be persisted.

最初,CurrentPosition等于0,然后在查询中使用类似WHERE ID = CurrentPosition + 1的方式进行检索,然后将CurrentPosition的值增加1.如果要返回结果,请减少1.

Initially CurrentPosition will equal 0, then in your query retrieve using like WHERE ID = CurrentPosition + 1, then increase the value of CurrentPosition by one. If navigating back in the results, decrease by 1.

这篇关于ASP.NET的下一个/上一个按钮以显示表单中的单行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆