0

i have a repeater control for showing products, i want to use pagination for showing some of the products on every page using pagination, but when dataset shows data on first page and i click Next page it shows an error of set page validation=true please help me with this

public partial class WebForm1 : System.Web.UI.Page
    {
        Database _db = DatabaseFactory.CreateDatabase();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                getdata();
            }
            else
            {
                getdata();
            }
         }
    public void getdata()
        {

            DataSet ds = new DataSet();
            DbCommand selectcmd = _db.GetStoredProcCommand("SHOPHIVESP");

            ds = _db.ExecuteDataSet(selectcmd);
            PagedDataSource Pds1 = new PagedDataSource();
            Pds1.DataSource = ds.Tables[0].DefaultView;
            Pds1.AllowPaging = true;
            Pds1.PageSize = 30;
            Pds1.CurrentPageIndex = CurrentPage;
            lbl1.Text = "Showing Page: " + (CurrentPage + 1).ToString() + " of " + Pds1.PageCount.ToString();
            btnPrevious.Enabled = !Pds1.IsFirstPage;
            btnNext.Enabled = !Pds1.IsLastPage;

            Repeater1.DataSource = Pds1;
            Repeater1.DataBind();

        }
        public int CurrentPage
        {
            get
            {
                object s1 = this.ViewState["CurrentPage"];
                if (s1 == null)
                {
                    return 0;
                }
                else
                {
                    return Convert.ToInt32(s1);
                }
            }

            set { this.ViewState["CurrentPage"] = value; }
        }
        public void btnPrevious_Click(object sender, EventArgs e)
        {
            CurrentPage -= 1;
            getdata();
        }
        public void btnNext_Click(object sender, EventArgs e)
        {
            CurrentPage += 1;
            getdata();
        }

    }
please tell me where the problem is, it is the code in c# and just a repeater at front in asp.net help me with this,i am using a stored procedure to select name image price from DB
  • Check this [Using Pagination with Repeater control in ASP.NET WEB FORM](http://stackoverflow.com/questions/22904666/using-pagination-with-repeater-control-in-asp-net-web-form) – Polynomial Proton May 29 '16 at 18:41
  • @TheUknown it is still giving me the same error whenever i click on button of Next page that error comes i don't know what to do now, please help – Shehroz Jalil May 30 '16 at 06:25

0 Answers0