Fix Pagination of DataViewWebPart in SharePoint Designer

The default pagination xsl:template of the DataViewWebPart (DVWP) contains a bug. When reaching the end of list, i.e. if you click on “end”, or on “next” until you reach the end, the total number of entries is not set correct anymore. If you click “previous” no items are shown anymore, as if the list is empty.

To fix this behaviour, first of all you have to activate the default pagination feature of the DVWP through SharePoint Desinger.

spd_pagination

First of all you have to find the template “dvt_1.navigation”
Second replace the existing code with following xslt code:

NOTE: Unfortunately WordPress removes the XML namespaces when saving , so I had to replace the colon with an underscore. To get the code to work replace “xsl_” with “xsl:”. Also xsl:value-of is automatically changed in xsl:value -of :-(… You have to fix that too…

To make the process easier, you can download the code here: pagination_code.txt.

Save the aspx page and reload it in the browser.

After all that the pagination should work as wished.
Additionally it now shows the total number of items which you page through and a link which brings you directly to the end.

  • Shaik

    Hi Matthias,

    Thanks for your excellent post, I have copied your code and replaced there are a few erros
    1. The tag is marked invalid because it is a mismatched end tag

    Could you please help me,
    Thanks in advance.

  • Hi Shaik,

    thank you for your comment. Unfortunately WordPress is messing up the whole xml code :-(
    I added a note to the end of the post where you can download the working xml.

    Matt

  • Shaik

    Thanks Matt!

    But you mentioned about “dvt_1.navigation” in your article, please suggest what need to be done!
    Thanks in advance!!

  • Shaik

    Hi Matt it would be better i f i can share print screen for this issue and then you can suggest me where i’m doing wrong. please share your email id. thanks!

  • dilip kumar

    Hi Matt,

    In our sharepoint site we have pagenation in the custom list .We have an issue in production the next goes indefinitely as we have only 35 items in the list. If a user is on the last page of the list, there should not be a forward arrow. The forward arrow allows the user to go ahead indefinitely . Below is the XSLT code for the pagenation


    javascript: ;
    Start

     

    javascript: history.back();


     


     


    javascript: ;

    Regards

    Dilip Kumar

  • Kannan

    Hi,
    First of all, i like mention a special thanks for posting this content. I recently started working XSLT and im stucked with paging issue. I tried your code and i able to see the first page, with 5 entries -> 5 of 30. But when clicking on Next, im getting an alert message “You must specify a value for this required field” and the page becomes blank. Please help on this issue asap..

    • Hey Kannan, it’s quite some time ago I wrote that, so will be hard for me too to figure out, but I try ;-)
      So actually you have to enable pagination through the properties of the DVWP in SharePoint Designer. If you haven’t done that the rest of the xml won’t work.

      I assume you have done that and that you are trying to achieve it in SharePoint 2007, so what exactly is shown on the page?
      What happens if you change the startrow parameter in the URL? Does it work then?

      Maybe you can just add you XML and I have a look at it.