代码如下:
1@ Page Language="C#" Debug="true"
< %@Import Namespace="System.Data"%>
< %@Import Namespace="System.Data.SqlClient"%>
1<script language="C#" runat="server">
2int Record_Per_Page;//定义每页显示记录数
3int nPageCount;//定义总页数
4int nRecCount;//定义总记录数
5int nPage;//定义当前页
6void Page_Load(Object src,EventArgs e){
7//取得当前页数值,并判断
8if(Request["pagesize"]==null)
9Record_Per_Page=9;
10else
11Record_Per_Page=Convert.ToInt32(Request["pagesize"]);
12//连接数据库
13SqlConnection conn;
14conn =new SqlConnection(ConfigurationSettings.AppSettings["strconn"]);
15conn.Open();
16
17//执行SQL语句
18string ConnStr="select id,name,demo,pic from download where classid=23 or classid=24 order by time desc";
19SqlDataAdapter odAdapt = new SqlDataAdapter(ConnStr,conn);
20DataSet DS = new DataSet();
21odAdapt.Fill(DS);
22DataTable DT = DS.Tables[0];
23//获得总记录数
24nRecCount = DT.Rows.Count;
25
26//判断是否存在数据记录
27if(nRecCount > 0){
28//确定数据记录要显示的页面数
29nPageCount=nRecCount/Record_Per_Page;
30if(nRecCount % Record_Per_Page > 0)
31nPageCount ++;
32if(nPage < 1)
33nPage = 1;
34if(nPage > nPageCount)
35nPage = nPageCount;
36//将页数显示到屏幕上,并作链接
37for(i=1;i<=nPageCount;i++){
38html=html+"<a href='mblist.aspx?page="+i+"&id="+classid+"&classname="+Request.Params["classname"]+"pagesize="+Record_Per_Page+"'>";
39if(i==nPage)
40html=html+"<b>"+i+"</b>";
41else
42html=html+i;
43html=html+"</a> ";
44}
45pagelist.InnerHtml=html;
46html="";
47//确认当前页面的开始记录和终止记录
48int nStart = Record_Per_Page * (nPage - 1);
49int nEnd = nStart + Record_Per_Page - 1;
50if(nEnd > nRecCount - 1)
51nEnd = nRecCount - 1;
52//在屏幕中输出记录
53html="<table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='95%' height='139' bgcolor='#ffffff'><tr>";
54int j=0;
55for(i=nStart;i<=nEnd;i++){
56html+="<td align=center height=180 ><table border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='145'><tr><td align=center><img src='http://bbs.wrclub.net/templates/"+DT.Rows[i]["demo"].ToString().Trim()+"/"+DT.Rows[i]["pic"].ToString().Trim()+"' height=143 width=140 border=0 alt='"+DT.Rows[i]["name"].ToString().Trim()+"'></td></tr><tr><td width='100%' background='images/mbbg.gif'><table border='0'cellpadding='0'cellspacing='0'width='100%'><tr><td width='50%'><a href='http://bbs.wrclub.net/templates/"+DT.Rows[i]["demo"].ToString().Trim()+"/' target='_blank'><img src='images/view.gif' border=0></a></td><td width='50%' align=right><a href='mbdown.aspx?id="+DT.Rows[i]["id"]+"' target=_blank><img src='images/down.gif' border=0></a></td></tr></table></td></tr></table></td>";
57j++;
58if(j%3==0)
59html+="</tr><tr>";
60}
61html+="</tr></table>";
62mblist.InnerHtml=html;
63html="";
64}
65conn.Close();
66}
67</script>
1<html>
2<head>
3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
4<title>```
5=Request.Params["classname"]
6```:网人俱乐部</title>
7<meta content="学习,免费资源,asp,jsp,flash,photoshop,社区,论坛,同学录,电子图书,网站建设,宣传,推广,聊天,数据库,经验心得,游戏,game,电子超市,网人交流论坛,插件,下载" name="Keywords"/>
8<meta content="提供网站建设、开发方面的学习资料、经验心得,同时提供免费的电子书籍、网站免费资源、制作工具、插件、滤镜,网站还有网上电子超市、论坛、网人交流论坛" name="description"/>
9<link href="style.css" rel="stylesheet" type="text/css"/><link href="favicon.ico" rel="Shortcut Icon"/>
10</head>
11<body leftmargin="0" topmargin="0"><form action="?id=22&classname=模板中心" runat="server">
12<!-- #Include File="top.inc" -->
13<div align="center">
14<center>
15<table border="0" bordercolor="#111111" cellpadding="0" cellspacing="0" height="92" style="border-collapse: collapse" width="778">
16<tr>
17<td height="92" rowspan="2" width="375"><img ```.jpg"="" height="92" id"]="" src="images/wrclub_l```
18=Request.Params[" width="375"/>
19</td>
20<td background="images/bg3.gif" height="24" width="403"> <span id="myclass" runat="server"></span></td>
21</tr>
22<tr>
23<td height="68" valign="top" width="403">
24<!-- #Include File="bbslogin.inc" --> </td>
25</tr>
26</table>
27<table border="0" cellpadding="0" cellspacing="0" width="778">
28<tr>
29<td background="images/bg5.gif" height="20"><img height="24" src="images/bg5.gif" width="7"/></td>
30</tr>
31</table>
32<table bgcolor="#D8D8D8" border="0" cellpadding="0" cellspacing="0" width="778">
33<tr>
34<td align="center" height="400" valign="top" width="562">
35<table bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0" width="95%">
36<tr>
37<td width="37%"> <img height="16" src="images/favorites.gif" width="16"/>
38<a href="default.aspx">网人俱乐部</a> \-- 模板中心</td>
39<td align="center" width="63%">·共有模板 ```
40=nRecCount
41``` 个 ·共有 ```
42=nPageCount
页 ·每页显示