All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
C#箴言:定义常量的两种方法_[Asp.Net教程]
SQL,Server,7.0,入门(三)_mssql学习_编程技术
asp.net实现站点RSS功能_[Asp.Net教程]
PHP中数组元素升序、降序及重新排序的函数_php资料_编程技术
XML入门教程-使用XSL显示XML_[XML教程]
ASP.NET,利用Outlook发送邮件_[Asp.Net教程]
实例:用PHP技术解决网站URL格式过长的问题_php资料_编程技术
如何在ASP.Net中实现RSA加密_.net资料_编程技术
AJAX能够取代桌面应用程序吗?_[AJAX教程]
在sqlserver2005中安装sql server 2000的示例数据库_[SQL Server教程]
Reading number is top 10 pictures
美女就是美女
真正的国产-非模拍 贵在是真实2
擦地板的大叔太好了
Beautiful vacuum girl2
美女和狗狗2
人美胸美腿更美1
世界各国15岁的MM有什么不同
The terra-cotta warriors3
The money of more than 100 countries and regions4
你是左脑型还是右脑型
Download software ranking
I'm come from Beijing2
Eclipse 4.2.2 For Win32
网络管理员第三版
功夫熊猫2(上集)
apache-tomcat-6.0.33
1400篇各类破解文章
Unix video tutorial12
C++教程第四版
Boxer's Top ten classic battle1
The cock of the Grosvenor LTD handsome
归海一刀 published in(发表于) 2014/1/30 1:28:44 Edit(编辑)
GridView自身的分页功能使用介绍_[Asp.Net教程]

GridView自身的分页功能使用介绍_[Asp.Net教程]

GridView自身的分页功能使用介绍_[Asp.Net教程]
(1)是否允许分页
GridView的AllowPaging属性。AllowPaging:是否允许分页。如果AllowPaging=“true”就是允许分页。否则就是不允许使用分页。
(2)每页记录数
GridView的PageSize属性。在GridView控件的属性中可以设置每页显示的数据记录的个数。默认情况下PageSize的值是10,也可以根据需要进行设置。
PagerSettings属性的Mode:Numeric,NextPrevious,NextPreviousFirstLast,NumericFirstLast。有这四种,可以根据不同需要进行不同的选择设置。
(3)在PagerSettings上设置显示的信息
例:现在想要在GridView控件上显示如下页码信息:首页、上一页、下一页、尾页。
AllowPaging="True"
PagerSettings FirstPageText="首页" LastPageText="尾页" Mode="NextPreviousFirstLast" NextPageText="下一页" PreviousPageText="上一页" 就行了。
另外添加一个GridView的
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
//重新让GridView显示一下数据的函数
}
//用lblCurrentIndex来显示当前页的页数。
LabelCurrentPage.Text = "第 " + (GridView1.PageIndex + 1).ToString() + " 页";
//用LblPageCount来显示当前数据的总页数。
LabelPageCount.Text = "共 " + GridView1.PageCount.ToString() + " 页";
GridView1.PageIndex为当前页属性,默认索引是从零开始的,GridView1.PageCount为总页数属性从1开始。
当选用自动套用格式后PagerSettings属性的Mode属性会变成Numeric

实例代码:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
static string sqlconn = "server=.;uid=sa;pwd=;database=StudentSystem";
SqlConnection conn = new SqlConnection(sqlconn);

protected void Page_Load(object sender, EventArgs e)
{
BindData();
// Label1.Text = "共 " + GridView1.PageCount.ToString() + " 页"; 显示总页数
Label1.Text = "第 " + (GridView1.PageIndex + 1).ToString() + " 页"; //显示当前页
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
BindData();
}
private void BindData()
{
conn.Open();
DataSet ds = CreateDataSet();
GridView1.DataSource = ds;
GridView1.DataBind();
conn.Close();

}
private DataSet CreateDataSet()
{
string strsql = "select * from studentinfo";
SqlCommand cmd = new SqlCommand(strsql, conn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
}


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.