我有一个html模板页面,用IO读出来后往里面添加数据,并且要实现分页功能,有谁做过的帮个忙!

解决方案 »

  1.   

    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    goALTER PROCEDURE [dbo].[Pr_Public_Page]
    (
    @tblName varchar(255), -- 表名 
    @strGetFields varchar(1000) = '*', -- 需要返回的列 
    @fldName varchar(255)='', -- 排序的字段名 
    @PageSize int = 10, -- 页尺寸 
    @PageIndex int = 1, -- 页码 
    @doCount bit = 0, -- 返回记录总数, 非 0 值则返回 
    @OrderType bit = 0, -- 设置排序类型, 非 0 值则降序 
    @strWhere varchar(1500) = '' -- 查询条件 (注意: 不要加 where) 
    )
    AS 
    declare @strSQL varchar(5000) -- 主语句 
    declare @strTmp varchar(110) -- 临时变量 
    declare @strOrder varchar(400) -- 排序类型 
    if @doCount != 0 
    begin 
    if @strWhere !='' 
    set @strSQL = 'select count(*) as Total from [' + @tblName + '] where '+@strWhere 
    else 
    set @strSQL = 'select count(*) as Total from [' + @tblName + ']' 
    end 
    --以上代码的意思是如果@doCount传递过来的不是0,就执行总数统计。以下的所有代码都是@doCount为0的情况 
    else 
    begin 
    if @OrderType != 0 
    begin 
    set @strTmp = '<(select min' 
    set @strOrder = ' order by [' + @fldName +'] desc' 
    --如果@OrderType不是0,就执行降序,这句很重要! 
    end 
    else 
    begin 
    set @strTmp = '>(select max' 
    set @strOrder = ' order by [' + @fldName +'] asc' 
    end 

    if @PageIndex = 1 
    begin 
    if @strWhere != '' 
    set @strSQL = 'select top ' + str(@PageSize) +' '+@strGetFields+ ' from [' + @tblName + '] where ' + @strWhere + ' ' + @strOrder 
    else 
    set @strSQL = 'select top ' + str(@PageSize) +' '+@strGetFields+ ' from ['+ @tblName + '] '+ @strOrder 
    --如果是第一页就执行以上代码,这样会加快执行速度 
    end 
    else 
    begin 
    --以下代码赋予了@strSQL以真正执行的SQL代码 
    set @strSQL = 'select top ' + str(@PageSize) +' '+@strGetFields+ ' from [' 
    + @tblName + '] where [' + @fldName + ']' + @strTmp + '(['+ @fldName + ']) from (select top ' + str((@PageIndex-1)*@PageSize) + ' ['+ @fldName + '] from [' + @tblName + ']' + @strOrder + ') as tblTmp)'+ @strOrder 
    if @strWhere != '' 
    set @strSQL = 'select top ' + str(@PageSize) +' '+@strGetFields+ ' from [' 
    + @tblName + '] where [' + @fldName + ']' + @strTmp + '([' 
    + @fldName + ']) from (select top ' + str((@PageIndex-1)*@PageSize) + ' [' 
    + @fldName + '] from [' + @tblName + '] where ' + @strWhere + ' ' 
    + @strOrder + ') as tblTmp) and ' + @strWhere + ' ' + @strOrder 
    end 
    end 
    exec (@strSQL)给个分面的存储过程给你! 你传相应的参数就可以了
      

  2.   


    他这个貌似是HTML分页<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <style type="text/css">
    <!--
    #ref {height: 27px;width: 728px;}
    #ref #zuo {width: 69px;float: left;}
    #ref #zuo a{display: block;width: 69px;height: 27px;text-decoration: none;background-image: url(1.jpg);background-position: -2px 0px;}
    #ref #zhong a {text-decoration: none;display: block;height: 27px;width: 16px;float: left;margin-right: 3px;margin-left: 3px;background-image: url(1.jpg);background-position: -70px 1px;background-repeat: no-repeat;}
    #ref #zhong a:hover{background-image: url(1.jpg);background-repeat: no-repeat;background-position: -98px 1px;}
    body {font-family: "新宋体";font-size: 12px;text-align: center;}
    #ref #zhong {float: left;}
    #ref #you {float: left;width: 69px;}
    #ref #you a {display: block;height: 27px;width: 69px;background-image: url(1.jpg);text-decoration: none;background-position: 55px 0px;}
    -->
    </style>
    </head><body>
    <div align="center">
    <div id="ref">
    <div id="zuo"><a href="?page=1"> </a></div>
    <div id="zhong">
    <a href="?page=1" id="1"> </a>
    <a href="?page=2" id="2"> </a>
    <a href="?page=3" id="3"> </a>
    <a href="?page=4" id="4"> </a>
    <a href="?page=5" id="5"> </a>
    <a href="?page=6" id="6"> </a>
    <a href="?page=7" id="7"> </a>
    <a href="?page=8" id="8"> </a>
    <a href="?page=9" id="9"> </a>
    <a href="?page=10" id="10"> </a>
    </div>
    <div id="you"><a href="?page=10"> </a></div>
    </div>
    </div>
    <script language="javascript">
    <!--
    var page=document.URL;
    var fen=page.split("?");
    var id=fen[1].split("=");
    document.write("点击第"+id[1]+"页,链接变成了蓝色!");
    document.getElementById(id[1]).style.backgroundPosition="-98px 1px";
    //-->
    </script>
    </body>
    </html> 
      

  3.   

    静态页分页方法。你先计算出页数,然后顺序生成
    xxx_1.htm
    xxx_2.htm
    xxx_3.htm等这样的文件即可
      

  4.   

       那个是html分页  楼主
      

  5.   

    哪位可以说的再详细点不,或者给个html分页的列子
      

  6.   

    asp.net生成html並分頁.
      

  7.   

    File.ReadAllText("")
    substring
    形成1_1.html,1_2.html...
    http://topic.csdn.net/u/20090410/13/de0a13c6-df06-419a-82a0-d646314317a3.html
      

  8.   

    <%@ page language="java" contentType="text/html; charset=gb2312"
        pageEncoding="gb2312"%>
        <%@ page import="java.sql.*" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>简单的Jsp分页技术</title>
    </head>
    <body>
    <%
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    String url="jdbc:mysql://localhost:3306/data";
    String user="root";
    String pass="root";
    Connection conn=DriverManager.getConnection(url,user,pass);
    String sql="select * from authors";
    PreparedStatement ps=conn.prepareStatement(sql);
    int intPageCount;
    int intRowCount;
    int intPageSize;
    int intPage;
    int intNext;
    int intPrev;
    int i;
    String strPage;
    strPage=request.getParameter("Page");
    if(strPage==null){
    intPage=1;
    }else{
    intPage=Integer.parseInt(strPage);
    }
    ResultSet rs=ps.executeQuery();
    rs.last();
    intPageSize=3;
    intRowCount=rs.getRow();
    intPageCount=(intRowCount+intPageSize-1)/intPageSize;
    if(intPage>intPageCount){
    intPage=intPageCount;
    }
    if(intRowCount<intPageSize){
    intPage=1;
    }
    if(intPage<0){
    intPage=1;
    }
    i=0;
    if(intRowCount>0){
    rs.absolute((intPage-1)*intPageSize+1);
    while(i<intPageSize&&!rs.isAfterLast()){
    out.println(rs.getString("au_id"+""+""+""));
    out.println(rs.getString("au_lname"+""+""+""));
    out.println(rs.getString("au_fname"+""+""+""));
    out.println(rs.getString("phone"+""+""+""));
    out.println(rs.getString("address"+""+""+""));
    out.println("<br/>");
    rs.next();
    i++;
    }
    rs.close();
    ps.close();
    }
    intNext=intPage+1;
    if(intNext>intPageCount){
    intNext=intPageCount;
    }
    intPrev=intPage-1;
    if(intPrev<1){
    intPrev=1;
    }

     %>
     共<%=intRowCount %>条记录
     共<%=intPageCount %>页
     每页显示<%=intPageSize %>条记录
     
     <a href="turn.jsp?Page=<%=intNext %>">下一页</a>
     <a href="turn.jsp?Page=<%=intPrev %>">上一页</a></body>
    </html>