public partial class PagedDataList : System.Web.UI.UserControl
{
clsGENERAL obj = new clsGENERAL();
DataSet ds = new DataSet();
public int CurrentPage
{
get
{
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 0;
else
return (int)o;
}
set
{
this.ViewState["_CurrentPage"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
ItemsGet();
}
private void ItemsGet()
{
ds = obj.SelectQuery("select * from category order by category");
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 10;
objPds.CurrentPageIndex = CurrentPage;
lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of "
+ objPds.PageCount.ToString();
cmdPrev.Enabled = !objPds.IsFirstPage;
cmdNext.Enabled = !objPds.IsLastPage;
repeaterItems.DataSource = objPds;
repeaterItems.DataBind();
}
protected void cmdNext_Click1(object sender, EventArgs e)
{
CurrentPage += 1;
ItemsGet();
}
protected void cmdPrev_Click1(object sender, EventArgs e)
{
CurrentPage -= 1;
ItemsGet();
}
}
No comments:
Post a Comment