PageAdmin网站内容管理系统(CMS)交流论坛

注册

 

QQ登录

只需一步,快速开始

发新话题 回复该主题

如何调用搜索结果总数 [复制链接]

1#
想在搜索结果页面显示搜索结果共有多少条,要怎么加呢
分享 转发
TOP
2#

你搜索模板写好了?可以发你的模板出来看看
TOP
3#

回复 2楼xiyou的帖子
  1. @{
  2.     int columnId = Html.CurrentColumnId();
  3.     string kw = StringHelper.Format<string>(HttpContext.Current.Request.QueryString["kw"]);
  4.     string[] pagePathArr = Html.PagePath().Split('/');
  5.     int currentPage = StringHelper.Format<int>(Html.CustomViewParameter("page"));
  6.     
  7.     
  8.     if (currentPage <= 0)
  9.     {
  10.         currentPage = 1;
  11.     }
  12.     PageInfo pageInfo = new PageInfo()
  13.     {
  14.         PageSize = 10,//每页显示10条数据
  15.         CurrentPage = currentPage, //当前页码,系统预设
  16.     
  17.     };
  18.     var dataList = Html.InfoDataList(new { Table = "news" ,OrderBy="thedate desc"},"title like @kw", new { kw = "%" + kw + "%" }, pageInfo);
  19.     ViewBag.Path = "/news/Search/"; //PagebreakPartial分页文件用到
  20. }
  21. <div class="container padding-bottom-60">
  22.     <ul class="breadcrumb">
  23.         <li><a href="@Html.SiteUrl()"><span class="fa fa-home"> 首页</span></a></li>
  24.         <li><a href="">文章搜索</a></li>

  25.     </ul>
  26.     <ul class="news-list padding-top-10">
  27.              <li style="border-bottom: 0px solid #dddbdb;">
  28.           <span>搜索</span>
  29.           <span style="color:#db3636">"@kw"</span>
  30.           <span>共找到</span>
  31.           <span style="color:#db3636">"<%=RecordCount%>"</span>
  32.           <span>篇文章</span>
  33.         </li>
  34.         @{int num = 0;
  35.             foreach (var item in dataList)
  36.             {
  37.                 num++;
  38.                 string url = Html.InfoDataUrl((int)item.ColumnId, (int)item.Id);
  39.                 string date = item.Thedate.ToString("yyyy-MM-dd");

  40.                 <li class="item">
  41.                     <span class="title" style="background: url([img]http://129.0.12.91/Templates/CompanyDefault/images/5-1.png[/img]) no-repeat left center;">
  42.                         <a href="@url" target="_blank" title="@item.Title">@item.Title</a>
  43.                     </span>
  44.                     <span class="date">@date</span>
  45.                 </li>
  46.             }
  47.             if (num == 0)
  48.             {
  49.             
  50.                 <li class="line-height-2 padding-bottom-20 padding-top-20" style="height: 300px;margin-left:500px;border-bottom: 0px solid #dddbdb;">
  51.             <img class="img4" referrerpolicy="no-referrer" src="http://129.0.12.91/Templates/CompanyDefault/images/not found2.png">
  52.                     <span class="word11">暂时没有找到匹配的记录</span>
  53.             <span class="info7">请更换一个关键词重新搜索!</span>
  54.                 </li>
  55.             }
  56.         }
  57.     </ul>
  58.      @Html.Partial("PagebreakPartial", pageInfo)
  59. </div>
  60. <script>
  61.     $("#input-search").val("@kw");
  62.     //$searchBtn.trigger("click");//触发搜索按钮,显示搜索框
  63. </script>
复制代码
TOP
4#

http://www.pageadmin.net/help/38.cshtml
pageinfo里面有一个属性是总记录数
TOP
5#

回复 4楼xiyou的帖子

好的!多谢!
TOP
发新话题 回复该主题