Re: Implementation Data Controls in asp.net hi,
Try this code Oxygen, its worked for me...,
The PagedDataSource class encapsulates the properties of the DataGrid control that allow it to perform paging. But we can use the class with Repeater and DataList controls to perform paging in much the same way as a DataGrid.
Body of the page
<table width="100%" border="0">
<tr >
<td> <asp:label ID="lblCurrentPage" runat="server">
</asp:label></td>
</tr>
<tr >
<td>
<asp:HyperLink id="lnkPrev" runat="server"><< Prev</asp:HyperLink>
<asp:HyperLink id="lnkNext" runat="server">Next >></asp:HyperLink></td>
</tr>
</table><asp:repeater ID="Repeater1" runat="server">
<itemtemplate>
<table width="100%" border="0">
<tr >
<td> <%# DataBinder.Eval(Container.DataItem, "Product") %> </td>
</tr>
<tr >
<td> </td>
</tr>
</table>
</itemtemplate>
</asp:repeater>
<script language="C#" runat="server">
public void Page_Load(Object src,EventArgs e) {
DataSet ds;
//Instanciate Dataset
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 5;
int CurPage;
if (Request.QueryString["Page"] != null)
CurPage=Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage=1;
objPds.CurrentPageIndex = CurPage-1;
lblCurrentPage.Text = "Page: " + CurPage.ToString();
if (!objPds.IsFirstPage)
lnkPrev.NavigateUrl=Request.CurrentExecutionFilePa th
+ "?Page=" + Convert.ToString(CurPage-1);
if (!objPds.IsLastPage)
lnkNext.NavigateUrl=Request.CurrentExecutionFilePa th
+ "?Page=" + Convert.ToString(CurPage+1);
Repeater1.DataSource=objPds;
Repeater1.DataBind();
}
< /script>
__________________ H2O
Without us, no one can survive.. |