软件开发学习笔记

我还要学很多东西chanllenge everyThing

PagedDataSource实现分页datalist,gridview。。。

 //分页按钮点击事件
    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);
        }
    } 

阅读更多
文章标签: object
上一篇using()
下一篇分层架构的模糊查询问题笨方法
想对作者说点什么? 我来说一句

PagedDataSource实现分页

2010年12月27日 1KB 下载

没有更多推荐了,返回首页

关闭
关闭