views:

192

answers:

1

Hi,

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.

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.

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.

+3  A: 

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;}
}

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

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.

ichiban
Thank you. Nice and simple solution.
Tommy Jakobsen