zoukankan      html  css  js  c++  java
  • 一个简单的分页代码

        今天看了一下同事写的分页代码 虽然效率不高 但是比我的简单多了
    数据量小的首选(别忘了定义gridview的pagesize)
    protected void LinkButton1_Click(object sender, EventArgs e)
        {
            GridView1.PageIndex = 0;
            BusinessWork BusinessWork = new BusinessWork();
            DataTable dt = new DataTable();
            dt = BusinessWork.BusinessWorkDataTable("Archives_DakfGetAll");
            if (dt.Rows.Count > 0)
            {
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
        }
        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            if (GridView1.PageIndex - 1 >= 0)
            {
                GridView1.PageIndex = GridView1.PageIndex - 1;
                BusinessWork BusinessWork = new BusinessWork();
                DataTable dt = new DataTable();
                dt = BusinessWork.BusinessWorkDataTable("Archives_DakfGetAll");
                if (dt.Rows.Count > 0)
                {
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                }
            }
        }
        protected void LinkButton3_Click(object sender, EventArgs e)
        {
            if (GridView1.PageIndex + 1 <= GridView1.PageCount)
            {
                GridView1.PageIndex = GridView1.PageIndex + 1;
                BusinessWork BusinessWork = new BusinessWork();
                DataTable dt = new DataTable();
                dt = BusinessWork.BusinessWorkDataTable("Archives_DakfGetAll");
                if (dt.Rows.Count > 0)
                {
                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                }
            }
        }
        protected void LinkButton4_Click(object sender, EventArgs e)
        {
            GridView1.PageIndex = GridView1.PageCount;
            BusinessWork BusinessWork = new BusinessWork();
            DataTable dt = new DataTable();
            dt = BusinessWork.BusinessWorkDataTable("Archives_DakfGetAll");
            if (dt.Rows.Count > 0)
            {
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
        }
  • 相关阅读:
    错误网络异常:android.os.NetworkOnMainThreadException
    方法服务android学习笔记42_服务的生命周期
    芯片软件随想录(关于核心技术)
    数组比特【编程珠玑】如何优化程序打印出小于100000的素数
    宋体函数Java乔晓松oracle分组函数
    调试客户端windbg远程调试方法
    方法对象Hibernate联合主键
    文件运行跟踪 root.sh 的 执行过程
    移植交叉编译pcDuino + busybox 成功搭建最小linux系统
    方法定制iOS学习笔记8UITableView的定制
  • 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/531460.html
Copyright © 2011-2022 走看看