zoukankan      html  css  js  c++  java
  • PagedDataSource给repeater分页

    DataTable dt = dbObject.BothEnExamCenter.FromSql(sql.ToString()).ToTable();

    int cup = this.drpCurrentPageIndex.SelectedValue == "" ? 1 : Convert.ToInt32(this.drpCurrentPageIndex.SelectedValue);

    PagedDataSource objPage = new PagedDataSource();

    objPage.DataSource = dt.DefaultView;

    objPage.AllowPaging = true;

    objPage.PageSize = Convert.ToInt32(drpCount.SelectedValue);

    objPage.CurrentPageIndex = cup - 1;

    ViewState["PageCount"] = objPage.PageCount;

    lbPageCount.Text = "一共" + ViewState["PageCount"] + "页"; 

    //绑定当前页

    if (!IsPostBack)

                {    //drpCurrentPageIndex.Items.Clear();

         for (int i = 1; i < Convert.ToInt32(ViewState["PageCount"]) + 1; i++) 

          {    this.drpCurrentPageIndex.Items.Add(i.ToString());

                    }  

      }           

      else             {  

                   //drpCurrentPageIndex.SelectedIndex = -1;      

               drpCurrentPageIndex.Items.Clear();        

             for (int i = 1; i < Convert.ToInt32(ViewState["PageCount"]) + 1; i++)                 {     

                    this.drpCurrentPageIndex.Items.Add(i.ToString());        

             }       

          }       

          drpCurrentPageIndex.SelectedValue = cup.ToString();     

            rpQuestionLine.DataSource = objPage;    

             rpQuestionLine.DataBind();

     protected void LinkUp_Click(object sender, EventArgs e)   

          {             if (Convert.ToInt32(drpCurrentPageIndex.SelectedValue) > 1)             {

                    drpCurrentPageIndex.SelectedValue = (Convert.ToInt32(drpCurrentPageIndex.SelectedValue) - 1).ToString();                 BindrpQuestionLine();             }             else             {                 PublicObject.PageHelper.Alert(this, "已经第一页");

                }         }

     protected void LinkDown_Click(object sender, EventArgs e)         {             if (Convert.ToInt32(drpCurrentPageIndex.SelectedValue) < Convert.ToInt32(ViewState["PageCount"]))             {                 drpCurrentPageIndex.SelectedValue = (Convert.ToInt32(drpCurrentPageIndex.SelectedValue) + 1).ToString();                 BindrpQuestionLine();             }             else             {                 PublicObject.PageHelper.Alert(this, "已经到了最后一页");             }         }

     protected void drpCurrentPageIndex_SelectedIndexChanged(object sender, EventArgs e)         {             int page = Convert.ToInt32((drpCurrentPageIndex.SelectedItem.Value));             BindrpQuestionLine();         }

     protected void LinkFirst_Click(object sender, EventArgs e)         {             this.drpCurrentPageIndex.SelectedValue = "1";             BindrpQuestionLine();         }

     protected void LinkLast_Click(object sender, EventArgs e)         {             this.drpCurrentPageIndex.SelectedValue = ViewState["PageCount"].ToString();             BindrpQuestionLine();         }

    protected void drpCount_SelectedIndexChanged(object sender, EventArgs e)         {             this.drpCurrentPageIndex.SelectedValue = "1";             BindrpQuestionLine();         }

  • 相关阅读:
    关于断电即关闭的电路设计
    Python-29_常用模块复习
    Python-28_组合_继承_多态_封装_反射
    Python-27_面向对象
    Python-26_模块-02_python内置模板
    Python-25_模块-01_调用基本操作、路径
    Python-24_综合练习-01_函数_文件处理_解耦--查询功能
    Python-23_装饰器-04_练习---无参装饰器、有参装饰器
    Python-22_装饰器-03_解压序列
    Python-21_装饰器-02_装饰器实现
  • 原文地址:https://www.cnblogs.com/liziqiang/p/3407108.html
Copyright © 2011-2022 走看看