0

I want to implement server side paging in my Silverlight application. To get an idea of the steps that I would require I went through this custom paging in asp.net article where they described how to design a SQL query to return the results according to the Page Requested and the Total no of records per page. I am however totally confused as to how am I going to call it from my Silverlight application. Like how am I going to specify it in the c# code.

The default paging using the DataPager is pretty simple.

PagedCollectionView pagingCollection = new PagedCollectionView(e.Result); //e.Result contains `List` returned by the method that calls the stored procedure GetProducts
pagerProductGrids.Source = pagingCollection;
gridProductGrid.ItemsSource = pagingCollection; 

But I'm clueless about the procedure of doing it on my own. Like what properties I will be needing to get and set the Page Size, the total no of records etc i.e how am I going to configure my DataGrid and DataPager to pass StartingRowIndex and Maximum RowcOunt

Please help!

Stack user
  • 47
  • 6

1 Answers1

0

I came across this article a few years ago and this worked like a charme for me. I've added this to my framework and have been reusing this method ever since. The article is well explained and I believe this is exactly what you are looking for.

Paging Data from the Server with Silverlight

Nkosi
  • 235,767
  • 35
  • 427
  • 472
  • Went through the article and yes, this is what I want to implement in my Application but I have few questions: I tried Implementing the `IPagedCollection` interface in my class and tried to set the value of `TotalItemCount` but I couldn't since its a `read-only`. So my question is Can I not implement this interface in my Code behind class? Why do I need to create a custom DataSource – Stack user Feb 01 '16 at 08:32
  • Quoting the article: `In order to make a generic/ re-useable implementation of this paging interface, I first created an interface that would act as the source of the data. This interface is very simple, having a single method that fetches data for the given page. The result is returned asynchronously, providing both the items within the given page and the total item count.` – Nkosi Feb 01 '16 at 09:58
  • Have you tried looking at the downloadable code sample at the end of the article? – Nkosi Feb 01 '16 at 12:35