Try the following Code
<asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" RepeatColumns="5" EnableViewState="true" Width="88%">
<itemtemplate>Xyz </itemtemplate>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='<%$ ConnectionStrings:ConnString %>'SelectCommand="SELECT x,y,z ...">
<tr>
<td>
<asp:Label ID="lblCurrentPage" runat="server" Visible="true">
</td>
</tr>
<tr>
<td align="center">
<asp:Button ID="cmdPrev" runat="server" Text=" << " OnClick="cmdPrev_Click">
<asp:Button ID="cmdNext" runat="server" Text=" >> " OnClick="cmdNext_Click">
</td>
</tr>
in the code behind :
protected void items()
{
PagedDataSource objDs = new PagedDataSource();
DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
objDs.DataSource = dv;
objDs.AllowPaging = true;
objDs.PageSize = 20;
objDs.CurrentPageIndex = CurrentPage;
lblCurrentPage.Text = "Page:" + (CurrentPage + 1).ToString() + " Of " + objDs.PageCount.ToString();
cmdPrev.Enabled = !objDs.IsFirstPage;
cmdNext.Enabled = !objDs.IsLastPage;
DataList1.DataSource = objDs;
DataList1.DataBind();
}
protected void cmdPrev_Click(object sender, EventArgs e)
{
try
{
CurrentPage -= 1;
items();
}
catch (Exception ex)
{
Logger.LogException(ex);
}
}
protected void cmdNext_Click(object sender, EventArgs e)
{
try
{
CurrentPage += 1;
items();
}
catch (Exception ex)
{
Logger.LogException(ex);
}
}
[Edit - disabled Treat my content as plain text, not as HTML option]