关闭

PagedDataSource实现分页datalist,gridview。。。

标签: object
753人阅读 评论(0) 收藏 举报

 //分页按钮点击事件
    protected void lnkbtnOnes_Click(object sender, EventArgs e)
    {
        this.labPages.Text = "1";
        BindDataSearch();
        this.dlistAnswered.Visible = false;
    }
    protected void lnkbtnUps_Click(object sender, EventArgs e)
    {
        this.labPages.Text = Convert.ToString(Convert.ToInt32(this.labPages.Text) - 1);
        BindDataSearch();
        this.dlistAnswered.Visible = false;
    }
    protected void lnkbtnNexts_Click(object sender, EventArgs e)
    {
        this.labPages.Text = Convert.ToString(Convert.ToInt32(this.labPages.Text) + 1);
        BindDataSearch();
        this.dlistAnswered.Visible = false;
    }
    protected void lnkbtnBacks_Click(object sender, EventArgs e)
    {
        this.labPages.Text = this.labBackPages.Text;
        BindDataSearch();
        this.dlistAnswered.Visible = false;
    }

 PagedDataSource pds = new PagedDataSource();

 public void BindSortData()
    {
        Model.Counseling CSL = new Model.Counseling();
        BLL.CounselingBLL BLL = new BLL.CounselingBLL();
        CSL.uid = Convert.ToInt32(uid);

        pds.DataSource = BLL.ShowDisease(CSL).DefaultView;
        //pds属性设置]
        int curpage = Convert.ToInt32(this.labPage.Text);
        pds.AllowPaging = true;
        pds.PageSize = 5; //每页显示大小
        pds.CurrentPageIndex = curpage - 1; //取得当前页的页码
        this.lnkbtnUp.Enabled = true;
        this.lnkbtnNext.Enabled = true;
        this.lnkbtnBack.Enabled = true;
        this.lnkbtnOne.Enabled = true;
        if (curpage == 1)
        {
            this.lnkbtnOne.Enabled = false;//不显示第一页按钮
            this.lnkbtnUp.Enabled = false;//不显示上一页按钮
        }
        if (curpage == pds.PageCount)
        {
            this.lnkbtnNext.Enabled = false;//不显示下一页
            this.lnkbtnBack.Enabled = false;//不显示最后一页
        }
        this.labBackPage.Text = Convert.ToString(pds.PageCount);
        //绑定呈现控件
        this.gvSort.DataSource = pds;
        this.gvSort.DataBind();
    }
    //自定义指定页
    public void ddlDate()
    {
        for (int i = 1; i <= pds.PageCount; i++)
        {
            ListItem item = new ListItem();
            item.Text = i.ToString();
            item.Value = i.ToString();
            this.ddlpages.Items.Add(item);
        }
    } 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:48923次
    • 积分:908
    • 等级:
    • 排名:千里之外
    • 原创:32篇
    • 转载:19篇
    • 译文:0篇
    • 评论:11条