• 分页算法


    function changepage(pages,page,parastr)
    dim str,sign
     str = ""
     if parastr = "" then
     sign = ""
     else
     sign = "&"
     end if
     str = str & "<div style='line-height: 150%;'>"
        str = str & "<table width=""520"" border=""0"" cellspacing=""0"" cellpadding=""0"">"&vbcrlf
     'str = str &"<form action=""ProductList.asp"" name=""Myform"" method=""post"">"
        str = str & "  <tr> "&vbcrlf
        str = str & "     <td height=""6""></td>"&vbcrlf
        str = str & "  </tr>"&vbcrlf
        str = str & "  <tr>"&vbcrlf
        str = str & "     <td bgcolor=""#CCCCCC"" height=""32"" align=""right"">(共"&iCount&"个产品) "&vbcrlf
     str = str &" -- 共 "&pages&" 页 "
     if page>1 then
      str = str & "<a href=""?page=1"&sign&parastr&""">首页</a>"
     else
      str = str & "首页"
     end if
     if page > 1 then
      str = str & "<a  href=""?page="&(int(page)-1)&sign&parastr&"""> 上一页 </a>"&vbcrlf
     else
      str = str & " 上一页 "&vbcrlf
     end if
     if int(page)>((page-1)\10)*10 and page>10 then
       str = str & "<a  href=""?page="&((int(page)-1)\10)*10&sign&parastr&""" onclink=""return false;"">上10页</a>"&vbcrlf
     end if 
     
     if ((int(page)-1)\10)*10 + 10 >= pages then
      endpage = pages
     else
      endpage = ((int(page)-1)\10)*10 + 10
     end if
     for i = ((int(page)-1)\10)*10+1 to endpage
      if i = int(page) then
       str = str & "<font color='FF0000' ><b>" &i& "</b></font> "&vbcrlf
      else
       str = str & "<a  href='?page="&i&sign&parastr&"'>"&i&"</a> "&vbcrlf
      end if
     next  
      
     if endpage <> pages then
       str = str & "<a  href='?page="&int(endpage+1)&sign&parastr&"' onclink=""return false;"">下10页</a>"&vbcrlf
     end if  
     if int(page)<int(pages) then
      str = str & "<a href=""?page="&(int(page)+1)&sign&parastr&"""> 下一页 </a>"
     else
      str = str & " 下一页 "
     end if
     if int(page)<int(pages) then
      str = str & "<a href=""?page="&(int(pages))&sign&parastr&""">末页 </a>" 
     else
      str = str &"末页 "
     end if
     str = str & "跳到"&vbcrlf
        str = str & "         <input type=""text"" name=""page"" size=""4"">页&nbsp;&nbsp;</td>"&vbcrlf
     str = str & "         <input type=""hidden"" name=""tp"" value="&sType_Code&">"&vbcrlf
     str = str & "         <input type=""hidden"" name=""BrandCode"" value="&sBrand_Code&">"&vbcrlf
        str = str & "  </tr>"&vbcrlf
     'str = str & "</form>"
     str = str & " </table>"&vbcrlf 
     str = str & "</div>"
     changepage = str
    end function


    private string CreatePage(int resultCount, int PageIndex, string keyWord, string cdoc_type, string cpush_date)
        {                                                                             
            int count;

            string ChannelCode = Request["ChannelCode"];
            //如果查询结果总数是页大小的整数倍

            keyWord = Server.UrlEncode(keyWord);
            cdoc_type = Server.UrlEncode(cdoc_type);
            cpush_date = Server.UrlEncode(cpush_date);
            if (resultCount % PageSize == 0)
            {
                count = resultCount / PageSize;
                //PageCount.Text = count.ToString();
            }
            else
            {
                count = resultCount / PageSize + 1;
                //PageCount.Text = count.ToString();
            }

            //分页显示的控制

            string URLpara = "&keyWord=" + keyWord + "&ChannelCode=" + ChannelCode + "&cdoc_type=" + cdoc_type + "&cpush_date=" + cpush_date + "&_T=1";
            string DivPageString = "共" + pageCount.ToString() + "页";

            //显示<上一页>
            if (PageIndex > 1)
            {
                DivPageString = DivPageString + "&nbsp;<a href=\"DiySearch.aspx?page=" +
                  (PageIndex - 1).ToString()
                  + URLpara
                  + "\">上一页</a>";
            }
            //显示当前页的面前几页
            //
            for (int i = PageIndex - DivPageIndex; i <= PageIndex - 1; i++)
            {
                DivPageString = DivPageString + "&nbsp;<a href=\"DiySearch.aspx?page=" +
                  i.ToString()
                  + URLpara
                  + "\">[" +
                  i.ToString()
                  + "]</a>";
            }

            //显示当前页
            DivPageString = DivPageString + "&nbsp;<font color='#FF0000'>[" + PageIndex.ToString() + "]</font>";
            //显示当前页的后前几页

            for (int i = PageIndex + 1; i <= PageIndex + 5; i++)
            {
                if (i > count) { break; }
                DivPageString = DivPageString + "&nbsp;<a href=\"DiySearch.aspx?page=" +
                  i.ToString()
                  + URLpara
                  + "\">[" +
                  i.ToString()
                  + "]</a>";

            }
            //显示<下一页>
            if (PageIndex < count)
            {
                DivPageString = DivPageString + "&nbsp;<a href=\"DiySearch.aspx?page=" +
                  (PageIndex + 1).ToString()
                  + URLpara
                  + "\">下一页</a>";
            }

            return DivPageString;

        }

  • 相关阅读:
    JS中的call()和apply()方法和bind()
    reactjs入门到实战(十)----one-first_app
    49-Reverse Linked List II
    48-Merge Sorted Array
    47-Generate Parentheses
    46.Valid Parentheses
    45-Letter Combinations of a Phone Number
    44-Count and Say
    43-Reverse Nodes in k-Group
    42-Remove Nth Node From End of List
  • 原文地址:https://www.cnblogs.com/goooto/p/1087096.html
Copyright © 2020-2023  润新知