gridview自带分页《续》

 1、<PagerSettings Visible="False" />
2、
currPage.Text = (GridView1.PageIndex + 1).ToString();
        thePage.Text = (GridView1.PageIndex + 1).ToString();
        pageCount.Text = GridView1.PageCount.ToString();
        txtRCount.Text = dt.Rows.Count.ToString();

        btnFirst.CommandName = "1";
        btnPrev.CommandName = (GridView1.PageIndex == 0 ? "1" : GridView1.PageIndex.ToString());
        btnNext.CommandName = (GridView1.PageCount == 1 ? GridView1.PageCount.ToString() : (GridView1.PageIndex + 2).ToString());
        btnLast.CommandName = GridView1.PageCount.ToString();
3、
protected void btnFirst_Click(object sender, EventArgs e)
    {
        int iPage = Convert.ToInt32(((LinkButton)sender).CommandName) - 1;
        if (iPage < 0)
            iPage = 0;
        GridView1.PageIndex = iPage;
        dataBindGridView ();
    }
    protected void btnPrev_Click(object sender, EventArgs e)
    {
        int iPage = Convert.ToInt32(((LinkButton)sender).CommandName) - 1;
        if (iPage < 0)
            iPage = 0;
        GridView1.PageIndex = iPage;
        dataBindGridView ();
    }
    protected void btnNext_Click(object sender, EventArgs e)
    {
        int iPage = Convert.ToInt32(((LinkButton)sender).CommandName) - 1;
        if (iPage < 0)
            iPage = 0;
        GridView1.PageIndex = iPage;
        dataBindGridView ();
    }
    protected void btnLast_Click(object sender, EventArgs e)
    {
        int iPage = Convert.ToInt32(((LinkButton)sender).CommandName) - 1;
        if (iPage < 0)
            iPage = 0;
        GridView1.PageIndex = iPage;
        dataBindGridView ();
    }
    protected void btnJump_Click(object sender, EventArgs e)
    {
        if (thePage.Text.Trim().ToString() != "")
        {
            int iPageIndex = int.Parse(thePage.Text.Trim().ToString());
            if (iPageIndex > GridView1.PageCount)
            {
                thePage.Text = GridView1.PageCount.ToString();
                iPageIndex = GridView1.PageCount;
            }
            if (iPageIndex < 1)
            {
                thePage.Text = "1";
                iPageIndex = 1;
            }
            GridView1.PageIndex = iPageIndex - 1;
            dataBindGridView();

        }
    }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值