PagerDataSource using an ObjectDataSource without paging support
This sample shows how to use the PagerDataSource to obtain data from an ObjectDataSource in order to populate a DataList.
In this sample our data mapper configured in the ObjectDataSource
does not
supports paging. To see an example where the ObjectDataSource
does support paging, choose the sample "Paging a DataSourceControl (1)".
What we want is to populate the DataList with items obtained from the ObjectDataSource
and also let the user choose the page of data to show. However, the ObjectDataSource
will return all the rows in the table (as we aren't using custom paging) but we
only want to show one page of data at a time. The PagerDataSource
we can solve this without writing a single line of code!
The PagerDataSource control acts as a data source and as a data
consumer. The DataList will consume the data exposed by the
PagerDataSource (the data of the current page), and the PagerDataSource will consume
the data exposed by
the ObjectDataSource.
Fortunately, the PagerDataSource also exposes full design time
information to the controls using it, so in design time we'll have all the type
information and fields of the underlying data source (check the design time integration
sample for more information).
The source code for this page is shown after the live sample.
Product List
|
1
|
|
Product 1
|
|
Full description for product number 1
|
|
2.00 $
|
|
|
2
|
|
Product 2
|
|
Full description for product number 2
|
|
4.00 $
|
|
|
3
|
|
Product 3
|
|
Full description for product number 3
|
|
6.00 $
|
|
|
4
|
|
Product 4
|
|
Full description for product number 4
|
|
8.00 $
|
|
|
5
|
|
Product 5
|
|
Full description for product number 5
|
|
10.00 $
|
|
|
6
|
|
Product 6
|
|
Full description for product number 6
|
|
12.00 $
|
|
|
7
|
|
Product 7
|
|
Full description for product number 7
|
|
14.00 $
|
|
|
8
|
|
Product 8
|
|
Full description for product number 8
|
|
16.00 $
|
|
|
9
|
|
Product 9
|
|
Full description for product number 9
|
|
18.00 $
|
|
|
10
|
|
Product 10
|
|
Full description for product number 10
|
|
20.00 $
|
|
|
11
|
|
Product 11
|
|
Full description for product number 11
|
|
22.00 $
|
|
|
12
|
|
Product 12
|
|
Full description for product number 12
|
|
24.00 $
|
|
|
13
|
|
Product 13
|
|
Full description for product number 13
|
|
26.00 $
|
|
|
14
|
|
Product 14
|
|
Full description for product number 14
|
|
28.00 $
|
|
|