Repeater and the PagedDataSource


Repeater and the PagedDataSource 
ASP.Net tutorial by Barbie Hocking  ©2010
Next Page           
The ASP.Net Repeater provides complete flexibility of a data bound layout.  One drawback of Repeaters is that they don't contain automated paging functionality.  This Visual Studio tutorial contains instructions on how to implement paging within a Repeater. 

This lesson uses the PagedDataSource class which encapsulates the paging-related properties of a data-bound control.  Since the entire SQL resultset is maintained in cache, this method is not suitable for large resultsets.
 This example uses a Repeater, but the same technique can be used for any data bound control.

For large resultsets, you can use the technique defined in the Add Paging to a DataList tutorial. That lesson defines how to define SQL functionality that returns only the rows that will display on a page.
C# Sample Code
1.  Create a web from and drag a repeater onto it.  Do not assign a DataSource. It will be assigned programatically.
 
2.  Assign the name rptOrderDetails to the Repeater.

Create an ItemDataBound event.  This isn't part of the paging functionality. It is used to display only the first occurrence of OrderId for orders sharing the same id.
 
3.  Create a SqlDataSource. Select a data connection. If you already have a connection string defined in your web.config, select that connection.  
 
4.  Select "Specify a custom SQL statement or stored procedure" in the "Configure the Select Statement" dialog.  
 
5.  Enter the SQL statement :
"select * from dbo.[Order Details Extended] order by OrderID"
 
 
6.  Select "Test Query" to validate the query.  If the results display, select "Finish".  
 
Next Page         
 Contact Us     Links      ©2010 GeekPhilosopher.com - All rights reserved
Powered by www.ezjooz.com