Home      |      Forum     |    Federal and State Jobs

DataList Paging

.NET Framework
ASP.NET
VB.NET
C#
ColdFusion
PHP

The DataList does not include inbuilt support for paging. By overloading the Fill method of the DataAdapter, however, you can create a paging mechanism for the DataList

  • Create a new web page in your project.
  • Add 4 LinkButtons.
  • Add three Labels.
  • Drag and drop a DataList on to the web page.
  • Right click on DataList then select - Edit Template - Header and Footer Templates

 
 In Header and Footer Templates add  header labels as below

Now open Item Templates

In Item Templates a table with 2 columns and add 2 lables as below

                                                                      

 

 

Now open HTML page by clicking HTML tab at the bottom of the form

 

Update <ItemTemplate> as below

 

Define 4 LinkButtons as

 ID

Text 

lkFirst

First

lkPrevious

Previous

lkNext

Next

lkLast

Last

Define 3 lable ID as intPageSize, intRecordCount, and intCurrIndex. Set Vesible FALSE
Now, its time to add  VB code to load DataList from SQL Server and do paging.

Imports System.Data.SqlClient

 

Finally we will add VB code for 4 LinkButtons:

Now run and navegate with First, Next, Previous and Last linkbuttons

     
 

Join WebHost4Life.com