asp:DataList has to paging option by default but it is easy to make pagination in datalist using “PagedDataSource Class”
HTML code is:
<table width=”100%”>
<tr><td>
<asp:DataList ID=”dlPhotos” Runat=”server” Width=”100%” ItemStyle-HorizontalAlign=”Left” RepeatLayout=”Table” RepeatDirection=”Horizontal” RepeatColumns=”4″ OnItemDataBound=”dlPhotos_ItemDataBound”>
<ItemTemplate>
<asp:Image id=”imgThumbnail” runat=”server” borderSize=”5″ />
</ItemTemplate>
</asp:DataList>
</td></tr>
<tr><td>
<table width=”100%”>
<tr>
<td align=”left”><asp:LinkButton runat=”server” ID=”lnkPrev” OnClick=”lnkPrev_Click” >Prev</asp:LinkButton></td>
<td align=”right”><asp:LinkButton runat=”server” ID=”lnkNext” OnClick=”lnkNext_Click” >Next</asp:LinkButton></td>
</tr>
</table>
</td></tr>
</table>
Code for the pagination is:
public void ShowPhotos()
{
try
{
PagedDataSource objPage = new PagedDataSource();
DataSet dsImgs = ….\datasource
objPage.AllowPaging=true;
objPage.DataSource = dsImgs.Tables[0].DefaultView;
objPage.PageSize = 12;
objPage.CurrentPageIndex = CurrentPage; //CurrentPage is a static variable
dlPhotos.DataSource = objPage;
dlPhotos.DataBind();
}
catch (Exception ex)
{
lblError.Text = ex.Message ;
}
}
protected void lnkPrev_Click(object sender, EventArgs e)
{
CurrentPage -=1;
ShowPhotos();
}
protected void lnkNext_Click(object sender, EventArgs e)
{
CurrentPage+=1;
ShowPhotos();
}
thats just a sample, please customize it for your works

