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

Reading number is top 10 articles
技巧:PHP开发网站程序代码的优化方法_php资料_编程技术
随机验证图片的产生,asp.net,2.0,c#,---在网页的特定或莫个位置显示图片_[Asp.Net教程]
SQL,Server连接基础知识的详细说明_[SQL,Server教程]
SQL,Server中读取XML文件的简单做法_[SQL,Server教程]
.net,2.0中新增的nullable类型_[Asp.Net教程]
在C#中调用视图
Asp.Net中文本换行_[Asp.Net教程]
掌握Ajax 第1部分-Ajax简介_[AJAX教程]
VC#2005快速入门之使用if语句_[Asp.Net教程]
apache的几个设置(目录,权限等)_[PHP教程]
Reading number is top 10 pictures
影评-疯子,我爱你
The real super beauty8
这酸爽,让人不敢相信
到南昌西站了1
Cesarean section, bloody, silently into it!1
ashlynn brooke
谁认识这位校花
胸部遭到偷窥的女人们
China telecom 114 spokesman MeiYanXu2
云南大理的美女
Download software ranking
c#程序设计案例教程
Kung fu panda - the secret of the teacher
Boxer's Top ten classic battle4
尖东毒玫瑰B
Unix video tutorial19
C#与.NET技术平台实战演练
Tram sex maniac 2 (H) rar bag5
致我们终将逝去的青春
Desire a peach blossom
Rio big adventure
delv published in(发表于) 2014/1/23 3:12:52 Edit(编辑)
C#生成静态页面的分页程序_[Asp.Net教程]

C#生成静态页面的分页程序_[Asp.Net教程]

C#生成静态页面的分页程序_[Asp.Net教程]

代码如下


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;
using System.IO;
using System.Text;


public partial class Default4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ //定义参数
StreamWriter sw = null;
string htmlfilename;
string path = HttpContext.Current.Server.MapPath("html/");
// 数据库生成分页

int onepage=10;
string ConnectionString = "连接字符串";
SqlConnection myConnection = new SqlConnection(ConnectionString);
string sSelect = "SELECT count(*) as pcount from 表名";
SqlCommand cmd = new SqlCommand(sSelect,myConnection);
myConnection.Open();
SqlDataReader Dr = cmd.ExecuteReader();
Dr.Read();
int Count=int.Parse(Dr["pcount"].ToString());

int allpages=Count/onepage;

for (int i = 0;i {



htmlfilename = "index_"+""+i+""+".html";

int start = i * onepage;

int nextpage=i+1;
int perpage=i-1;

if (nextpage==allpages)
{
nextpage=i;
}

if (perpage==-1)
{
perpage=0;

}


// 写文件
try
{


SqlConnection gConnection = new SqlConnection(ConnectionString);
gConnection.Open();
string vQuery = "SELECT TOP "+onepage+" * FROM 表名 WHERE (ID NOT IN (SELECT TOP "+start+" Id FROM 表名 ORDER BY id)) ORDER BY ID";
SqlDataAdapter vmd = new SqlDataAdapter(vQuery,gConnection);
DataSet ds=new DataSet();
vmd.Fill(ds,"table1");
DataTable dt=ds.Tables["table1"];



sw = new StreamWriter(path + htmlfilename , false, Encoding.GetEncoding("GB2312"));
foreach(DataRow dr in dt.Rows)
{
sw.WriteLine(""+dr["字段名"].ToString()+dr["字段名"]+"
");
}

sw.WriteLine("上一页");
sw.WriteLine("下一页");
sw.Flush();
}
catch(Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
HttpContext.Current.Response.End();
}
finally
{
sw.Close();
}
}
}
}


来源:CSDN






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