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

Reading number is top 10 articles
asp.net页面导出为Excel文档_[Asp.Net教程]
技巧应用:ASP.NET中文件上传下载方法集合_.net资料_编程技术
学习PHP小结:PHP编程中常用的三则技巧_[PHP教程]
phpMyAdmin2.6以上版本数据乱码问题_[PHP教程]
初学PHP指导:php.ini 配置详细选项_[PHP教程]
C#中的GDI+概述
php论坛服务器架构_[PHP教程]
如何对PHP程序中的常见漏洞进行攻击_[PHP教程]
符合web标准的媒体播放器代码_[Html教程]_0
PHP+MySQL应用中使用XOR运算加密算法_[PHP教程]
Reading number is top 10 pictures
女人化妆前后的对比
The hot big eye big breast beauty3
Absolutely shocked. National geographic 50 animal photographys9
Sexy women in 2013--1
Flow chart of breast implants
Seductive beauty of crime1
小学生作文又现神作,你不得不佩服
这才叫绝色美女1
海底兵马俑
关于海盗的研究
Download software ranking
Unix video tutorial12
Wild things 2
Boxer's Top ten classic battle7
株洲本地在线棋牌游戏
中国结婚习俗实录
C语言教程TXT
超级战舰
Tram sex maniac 2 (H) rar bag10
Boxer Classic video3
网络管理员第三版
归海一刀 published in(发表于) 2014/1/30 1:57:31 Edit(编辑)
简单实用的DataGrid自定义分页源程序_[Asp.Net教程]

简单实用的DataGrid自定义分页源程序_[Asp.Net教程]

简单实用的DataGrid自定义分页源程序_[Asp.Net教程]
首先新建一个名为article.aspx的文件,将以下内容拷贝到article.aspx.cs中:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 article : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int cpage = Convert.ToInt32(Request.QueryString["page"]);
if(cpage==0)
{
this.hlFrontPage.NavigateUrl = Request.ServerVariables["SCRIPT_NAME"];
this.hlNextPage.NavigateUrl = Request.ServerVariables["SCRIPT_NAME"] + "?page=" + Convert.ToString(cpage + 2);
}
else
{
this.hlFrontPage.NavigateUrl = Request.ServerVariables["SCRIPT_NAME"] + "?page=" + Convert.ToString(cpage - 1);
this.hlNextPage.NavigateUrl = Request.ServerVariables["SCRIPT_NAME"] + "?page=" + Convert.ToString(cpage + 1);
}
this.hlFirstPage.NavigateUrl = Request.ServerVariables["SCRIPT_NAME"];
dataBin();
//***************************************************
//PageCount的值必须在数据绑定之后才能得到,否则只能是0
//***************************************************
int lastPage =this.DataGrid1.PageCount;//lastPage是记录总页数
this.hlLastPage.NavigateUrl = Request.ServerVariables["SCRIPT_NAME"] + "?page="+Convert.ToInt32(lastPage);
if (cpage ==Convert.ToInt32(this.DataGrid1.PageCount))
{
this.hlNextPage.NavigateUrl = Request.ServerVariables["SCRIPT_NAME"] + "?page=" + Convert.ToString(lastPage);
this.hlFrontPage.NavigateUrl = Request.ServerVariables["SCRIPT_NAME"] + "?page=" + Convert.ToString(cpage - 1);
}
this.lbShowMess.Text= "当前第"+Convert.ToInt32(this.DataGrid1.CurrentPageIndex+1)+"页";
}
public void dataBin()
{
DB mydb = new DB();
SqlConnection conn = mydb.createConn();
conn.Open();
SqlDataAdapter sdr = new SqlDataAdapter();
DataSet ds = new DataSet();

sdr.SelectCommand = new SqlCommand("select * from [User]", conn);
sdr.Fill(ds, "users");

int page=Convert.ToInt32(Request.QueryString["page"]);
if (page == 0)
{
page = 1;
}
this.DataGrid1.CurrentPageIndex =Convert.ToInt32(page-1);
this.DataGrid1.DataSource = ds.Tables["users"];
this.DataGrid1.DataBind();
conn.Close();
}
protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{

}
}

再将以下内容拷贝到article.aspx中

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="article.aspx.cs" Inherits="article" %>



无标题页











<%# DataBinder.Eval(Container.DataItem,"id") %>


Font-Underline="False" HorizontalAlign="Left" />



<%# DataBinder.Eval(Container.DataItem,"Uid") %>

Font-Underline="False" HorizontalAlign="Left" />




<%# DataBinder.Eval(Container.DataItem,"title") %>


Font-Underline="False" HorizontalAlign="Center" />



" />


Font-Underline="False" HorizontalAlign="Center" />









首页
上一页
下一页

末页







添加到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.