These handlers call the PreviousPage and NextPage functions respectively. These two functions are very similar. Since the DataView that displays the information about Mix presenters is an ASP.NET AJAX component, it takes the id of the DOM element to which it is attached, and can be found using ASP.NET AJAX’s $find method. To make the Data Service return the correct page of data, we set two fetch parameters. We saw fetch parameters in my previous post, where they were set with an attribute of the html element to which the DataView was attached. In that case, we used only the $top parameter, which tells the Data Service how many records to return. Now, in addition to $top, we are using $skip, which tells the Data Service to skip over so many records, and then return the number of records specified by the $top parameter. The number of records to return at once is specified by the global ItemsPerPage variable. The global CurrentPage variable keeps track of which page is currently being shown, and is used to calculate the value of the $top parameter. Once the fetch parameters have been set, the fetchData method retrieves the required data and inserts it into our table. The value of CurrentPage is then increased or decreased as appropriate.
The only significant difference between the NextPage and PreviousPage functions is the existence in the latter of an if statement to determine when the first page is being displayed. As mentioned above, ADO.NET Data Services has no count method, so it is impossible to know when the last page of data has been reached. To get around this problem, I added an attribute in the html that adds a handler to the DataView’s fetchsucceeded event: