..


Sponsored Links

Paging of an XML document using ASP.NET

Article written by Luca Ruggiero
Page 1 of 2

The. NET Framework provides valuable tools for managing XML documents, either through native classes through classes provided by ADO.NET.

In this article we look at an example of an XML document paging with ASP.NET using a Repeater to print to video data, a DataSet to light and class to run PagedDataSource paging data.

We will work in the file paginazione.aspx that, after completion of all operations, will look as follows:

Thus we see that it is a web page where we display 3 of N available data, we display the current page number and total number of pages and, finally, the navigation links between pages that are not active when the page Current is the first or the last.

We create the XML document that contains the data or the file that will persone.xml the following structure:






 <? Xml version = "1.0" encoding = "ISO-8859-1"?>







 <persone>



    



 <persona>



        



 Maximilian <name> </ name>



        



 <Last Bossi </ name>



    



 </ Person>



    



 <persona>



        



 <name> Luke </ name>



        



 <Last Ruggiero </ name>



    



 </ Person>



    



 <persona>



        



 <name> Claudio </ name>



        



 <Last Garau </ name>



    



 </ Person>



    



 <persona>



        



 <name> Gennaro </ name>



        



 <Last Veneroso </ name>



    



 </ Person>



    



 <persona>



        



 <name> Maria </ name>



        



 <Last Bonora </ name>



    



 </ Person>







 </ Person>



Let us now see the HTML that will be contained in the body of the web page:





 <form runat="server">

 





 <asp:repeater id="risultati" runat="server">



    



 <ItemTemplate>



        



 <p>



            



 <% # Container.DataItem ("name")%>



            



 <% # Container.DataItem ("name")%>



        



 </ P>



    



 </ ItemTemplate>

 





 </ Asp: Repeater>

 





 <p> <asp:literal id="pagina" Text="1" runat="server" /> </ b> </ p>







 <p>



    



 <asp:hyperlink id="indietro" runat="server" Text="Indietro" /> |



    



 <asp:hyperlink id="avanti" Text="Avanti" runat="server" />







 </ P>







 </ Form>



We build the repeater in which print data, therefore a server-side text to print the current page and total number of pages and links (also server side) to navigate between pages.

In order to make more pleasant the final output, we apply the page a bit of CSS:






 <style type="text/css">







 Body







 {



    



 background: # FFFFFF;



    



 color: # 000000;



    



 margin: 10px 10px 10px 10px;







 }







 p







 {



    



 font-size: 13px;



    



 font-family: verdana;







 }







 to







 {



    



 color: # 0000FF;



    



 text-decoration: none;







 }







 a: hover







 {



    



 color: # FF0000;



    



 text-decoration: none;







 }







 a.nolink







 {



    



 color: # AAAAAA;







 }







 </ Style>



Note the CSS class "nolink" that invoked via ASP.NET code to mark as "clickable" links "back" and "forward" in the case of the first or last page of data.

In the same category ...
E-Learning
ASP (Advanced) ASP (Advanced)
Full course for creating dynamic Web sites. From 39 €.
ASP.NET (Course) ASP.NET (Course)
Full course for building Web applications from 49 €.
SQL and Database (Course) SQL and Database (Course)
Create and manage relational databases. From 39 €.
Sponsored Links