海力源码logo图片
400电话图片
热门关键词:  响应式网站    设计网站    营销型网站   
源码资讯
当前位置:首页 > 源码资讯 > GOODNET CMS怎么添加相关资讯

GOODNET CMS怎么添加相关资讯

资讯来源:海力源码    点击次数:897    更新时间:2020-8-28 16:21:24
在资讯详情页面中,通常都有相关资讯这个模块,那么,如果没有的话,如何添加相关资讯呢?
1、添加Repeater控件
<div class="newstj">
<ul>
<asp:Repeater ID="rp_NewsList2" runat="server">
<ItemTemplate>
  <li><span><%#Eval("AddTime","{0:MM-dd}") %></span>
  <a href="news_detail-<%#Eval("NewsID") %>.html" title="<%#Eval("NewsTitle") %>"><%#cutstr(Eval("NewsTitle").ToString(), 18)%></a>
  </li>
</ItemTemplate>
</asp:Repeater>    
</ul>
</div>

2、 在news_detail.aspx.cs页面中,添加如下代码:
//相关资讯
string Splitkwds = SeoKeywords;
string[] arrstr = Splitkwds.Split(new char[] { ',', ';', ' ' });
for (int i = 0; i < arrstr.Length; i++)
{
     if (i == 0)
    {
        NewsSearchCondition = "SeoKeywords like \'%" + arrstr[i] + "%\'";
    }
    else
    {
        NewsSearchCondition = NewsSearchCondition + " or SeoKeywords like \'%" + arrstr[i] + "%\'";
    }
     NewsSearchCondition = "NewsID<>" + newsID + "and (" + NewsSearchCondition + ")";
     strSql = "";

     strSql = "select top 12 NewsID,ClassID,NewsTitle,SEOTitle,SeoKeywords,SeoDesc,ClickTimes,AddWho,AddTime,ClassName From 
     cai_V_News where " + NewsSearchCondition + " order by NewsID desc";

     DataView dvlist_news2 = News.QueryNews(strSql);
     rp_NewsList2.DataSource = dvlist_news2;
     rp_NewsList2.DataBind();
}


  • 海力源码手机版
  •  联系客服小美