易截截图软件、单文件、免安装、纯绿色、仅160KB

像ASP一样轻松实现分页显示数据C#

 
代码如下:
<%@ Page Language="C#" Debug="true" %>
<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.SqlClient"%>
<Script Language="C#" runat="server">
int Record_Per_Page;//定义每页显示记录数
int nPageCount;//定义总页数
int nRecCount;//定义总记录数
int nPage;//定义当前页
void Page_Load(Object src,EventArgs e){
//取得当前页数值,并判断
if(Request["pagesize"]==null)
Record_Per_Page=9;
else
Record_Per_Page=Convert.ToInt32(Request["pagesize"]);
//连接数据库
SqlConnection conn;
conn =new SqlConnection(ConfigurationSettings.AppSettings["strconn"]);
conn.Open();
//执行SQL语句
string ConnStr="select id,name,demo,pic from download where classid=23 or classid=24 order by time desc";
SqlDataAdapter odAdapt = new SqlDataAdapter(ConnStr,conn);
DataSet DS = new DataSet();
odAdapt.Fill(DS);
DataTable DT = DS.Tables[0];
//获得总记录数
nRecCount = DT.Rows.Count;
//判断是否存在数据记录
if(nRecCount > 0){
//确定数据记录要显示的页面数
  nPageCount=nRecCount/Record_Per_Page;
if(nRecCount % Record_Per_Page > 0)
 nPageCount ++;
if(nPage < 1)
    nPage = 1;
if(nPage > nPageCount)
    nPage = nPageCount;
//将页数显示到屏幕上,并作链接
for(i=1;i<=nPageCount;i++){
   html=html+"<a href='mblist.aspx?page="+i+"&id="+classid+"&classname="+Request.Params["classname"]+"pagesize="+Record_Per_Page+"'>";
   if(i==nPage)
   html=html+"<b>"+i+"</b>";
   else
   html=html+i;
   html=html+"</a> ";
  }
  pagelist.InnerHtml=html;
  html="";
//确认当前页面的开始记录和终止记录
  int nStart = Record_Per_Page * (nPage - 1);
  int nEnd = nStart + Record_Per_Page - 1;
if(nEnd > nRecCount - 1)
    nEnd = nRecCount - 1;
//在屏幕中输出记录
  html="<table border='0' cellpadding='0' cellspacing='0' style='border-collaps


相关文档:

C# xml解析

已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
<price>5.95</price& ......

ASP FSO文件处理函数大全

<%
'建立文件夹函数
Function CreateFolder(strFolder)'参数为相对路径
'首选判断要建立的文件夹是否已经存在
Dim strTestFolder,objFSO
strTestFolder = Server.Mappath(strFolder)
Set objFSO = CreateObject("Scripting.FileSystemObject")
'检查文件夹是否存在
If not objFSO.FolderExists(strTestF ......

解决asp utf 8 access中文乱码一例

 文件头用了
<%@Language="VBScript" CodePage="65001"%>
文件本身已经是Utf-8的编码了
提交过到Access库中怎么都是 “&#20135;&#21697;&#20171;&#32461 ”这样的编码
一步步分析,不存库直接输出,也是这样的编码。想来跟Access无关了。
相于迷惑,后来重新建一个表单元,提交 ......

ASP实例:幻灯片新闻代码

以下为引用的内容:
<!--这是一个主页文件-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>幻灯片新闻</title>
</head>
<body>
<!--#Include file="diaoyong.asp"-->
</body>
</html>
& ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号