真分页和假分页
来源:互联网 发布:mac pro 重新安装系统 编辑:程序博客网 时间:2024/04/29 09:22
假分页:从数据库一次性取出所有数据绑定到控件上,再将所有数据根据每页显示记录条数进行分页。
使用GridView控件来达到分页的功能:
<span style="font-size:18px;"><%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="牛腩新闻发布系统.test" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title> </title> </head> <body> <form id="form1" runat="server"> <asp:GridView ID="GridViewText" runat="server" AllowPaging="True" onpageindexchanging="GridViewText_PageIndexChanging" PageSize="10"> </asp:GridView> </form> </body> </html></span>
数据绑定:
<span style="font-size:18px;">using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.Security;using BLL;using DAL;namespace 牛腩新闻发布系统{ public partial class test : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { BindNews(); } } private void BindNews() { GridViewText.DataSource = new B_Page().SelectAll(); GridViewText.DataBind(); } Protected void GridViewText_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridViewText.PageIndex = e.NewPageIndex; BindNews(); } } }</span>
设置一下GridView的一些属性:
真分页:在执行查询操作的时候,只查询当前页面的要显示的内容。每次跳转页面也都要查询数据库取对应数据。
真分页需要使用ASPNETPAGERT控件。
<span style="font-size:18px;"><%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="牛腩新闻发布系统.test" %><%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <webdiyer:AspNetPager ID="anp" runat="server" onpagechanged="anp_PageChanged" PageSize="10"> </webdiyer:AspNetPager> </form></body></html></span>
显示记录数:
<span style="font-size:18px;">using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.Security;using BLL;using DAL;namespace 牛腩新闻发布系统{ public partial class test : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { anp.RecordCount = 56; } } protected void anp_PageChanged(object sender, EventArgs e) { Response.Write("开始记录数:" + anp.StartRecordIndex + " <br>结束记录数:" + anp.EndRecordIndex); } }}</span>
假分页其实就是从数据库中选择所有的记录后再进行分页,它要把所有信息都调出来后才进行分页。
真分页是只从数据中选择当前页的记录,它只要那一页的记录,其他的记录不调用,查询速度更加快速,适合数据量较大时候使用。
0 0
- 真分页和假分页
- 真分页和假分页
- 真分页与假分页介绍
- “真分页”与“假分页”的实现方法
- 浅论Hibernate分页的“真”与“假”
- 浅论Hibernate分页的“真”与“假”
- jqGrid之真分页
- bootstrap-table真分页
- 我们一起来探究—真分页,假分页 轻松实现分页的功能
- ASP.NET真假分页—真分页
- ASP.NET真假分页—真分页
- Java分页查询(真分页)
- layui完美分页,ajax请求分页(真分页)
- [置顶] layui完美分页,ajax请求分页(真分页)
- 用Gridview和AspNetPager控件实现真分页(一)
- 用Gridview和AspNetPager控件实现真分页(二)
- ROW_NUMBER() 真分页 存储过程
- easyUI datagrid 前端真分页
- sublime 中的快捷键以及使用技巧
- 猜数字
- 移动终端播放器的探索历程
- Android组件之服务---Service
- 不容易系列之一
- 真分页和假分页
- ScrollView嵌套ListView
- googlesamples/android-topeka学习笔记(三)-----undone
- poj 2774 Long Long Message(后缀数组)
- 程序员养生
- 操作系统——文件管理
- linux 处理键盘 鼠标事件
- Mysql IO 内存方面的优化
- 【数据库】 存储过程