Here is the code that you can write in your .aspx file to use a DataPager
control.
Note that you can specify the list control with which you want to enable paging
using the PagedControlID and you can set the page size of your choice using the
PageSize property. I will now illustrate how easily you can achieve customized
paging with the ListView control using a DataPager. Here is the code that you need
to write in your .aspx file.
DataSourceID="SqlDataSource1"
DataKeyNames="EmployeeID" ItemContainerID="SqlDataSource1">
Chapter 8
[ 225 ]
EmployeeID |
EmployeeName |
JoiningDate |
Salary |
DepartmentID |
|---|
runat="server">
Text='<%# Eval("EmployeeID") %>'/>
|
Text='<%# Eval("EmployeeName") %>'/>
|
Text='<%# Eval("JoiningDate") %>'/>
|
|
Text='<%# Eval("DepartmentID") %>'/>
|
Working with LINQ
[ 226 ]
ConnectionString="<%$
ConnectionStrings:joydipConnectionString %>"
SelectCommand="SELECT [EmployeeID], [EmployeeName],
[JoiningDate], [Salary], [DepartmentID] FROM [Employee]">
And, here is the output when you execute the sample application.
Pages:
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212