repeater控件分页

    #region 数据源绑定、分页
    ///


    /// 初始数据绑定
    ///

    public void dataBindToRepResouce(string condition)
    {
        if (condition == "")
        {
            condition = "1=1 order BY [ID] DESC";
        }
        else
        {
            condition += " order BY [ID] DESC";
        }
        int curpage = Convert.ToInt32(this.LA_Page.Text);
        PagedDataSource ps = new PagedDataSource();

        DataSet ds = Resouce.GetList(condition);//根据条件绑定资源,表示数据在内存中的缓存
        ps.DataSource = ds.Tables[0].DefaultView;//获取可能包括筛选视图或游标位置的表的自定义视图
        ps.AllowPaging = true;//允许分页
        ps.PageSize = 8;//每页8个
        ps.CurrentPageIndex = curpage - 1;//获取或设置当前页的索引
        this.LBT_Home.Enabled = true;//首页
        this.LBT_Pri.Enabled = true;//上一页要
        this.LBT_Next.Enabled = true;//下一页
        this.LBT_Tail.Enabled = true;//尾页

        if (curpage == 1)
        {
            this.LBT_Pri.Enabled = false;//上一页

        }
        if (curpage == ps.PageCount)//获取显示数据源中的所有项所需要的总页数
        {
            this.LBT_Next.Enabled = false;
        }

        this.lA_Count.Text = Convert.ToString(ds.Tables[0].Rows.Count);
        this.LA_PageCount.Text = Convert.ToString(ps.PageCount);
        this.RepResource.DataSource = ps;
        this.RepResource.DataBind();

        this.DropPage.Items.Clear();
        for (int i = 1; i <= Convert.ToInt32(this.LA_PageCount.Text); i++)
        {
          
            this.DropPage.Items.Add(new ListItem("第" + i.ToString() + "页", i.ToString()));
           
        }
        this.DropPage.SelectedIndex = Convert.ToInt32(this.LA_Page.Text) - 1;
    }
    ///


    /// 绑定类别信息
    ///

    public void dataBindToDDlType()
    {
        this.DDL_Type.DataSource = type.GetList("");
        this.DDL_Type.DataTextField = "Style";
        this.DDL_Type.DataValueField = "ID";
        this.DDL_Type.DataBind();
    }
    ///
    /// 绑定类别信息
    ///

    public void dataBindToSerchDDlType()
    {
        this.DDL_Stype.DataSource = type.GetList("");
        this.DDL_Stype.DataTextField = "Style";
        this.DDL_Stype.DataValueField = "ID";
        this.DDL_Stype.DataBind();
        this.DDL_Stype.Items.Insert(0, new ListItem("--请选择类别--", "0"));///添加默认选中项
    }
    ///
    /// 获取类别名
    ///

    ///
    ///
    public string getType(object value)
    {
        string typeid = Convert.ToString(value);
        string ss;
        ss = type.getTypeName(typeid);
        return ss;
    }
    public string getType(string id)
    {
        string typeid = id;
        string ss;
        ss = type.getTypeName(typeid);
        return ss;
    }
    ///
    /// 首页
    ///

    ///
    ///
    protected void LBT_Home_Click(object sender, EventArgs e)
    {
        this.LA_Page.Text = "1";
        querycondition = SearchCondition();
        this.dataBindToRepResouce(querycondition);
    }
    ///
    /// 上一页
    ///

    ///
    ///
    protected void LBT_Pri_Click(object sender, EventArgs e)
    {
        this.LA_Page.Text = Convert.ToString(Convert.ToInt32(this.LA_Page.Text) - 1);
        querycondition = SearchCondition();
        this.dataBindToRepResouce(querycondition);
    }
    ///
    /// 下一页
    ///

    ///
    ///
    protected void LBT_Next_Click(object sender, EventArgs e)
    {
        this.LA_Page.Text = Convert.ToString(Convert.ToInt32(this.LA_Page.Text) + 1);
        querycondition = SearchCondition();
        this.dataBindToRepResouce(querycondition);
    }
    ///
    /// 尾页
    ///

    ///
    ///
    protected void LBT_Tail_Click(object sender, EventArgs e)
    {
        this.LA_Page.Text = this.LA_PageCount.Text;
        querycondition = SearchCondition();
        this.dataBindToRepResouce(querycondition);
    }
    ///
    /// 转至
    ///

    ///
    ///
    protected void DropPage_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.LA_Page.Text = this.DropPage.SelectedValue.ToString();
        querycondition = SearchCondition();
        this.dataBindToRepResouce(querycondition);
    }
    #endregion 数据源绑定、分页



本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部