复制代码 代码如下:
/// <summary>
/// 获取新闻数据列表
/// </summary>
/// <param>请求数量</param>
/// <param>类别ID</param>
/// <param>是否置顶</param>
/// <param>是否推荐</param>
/// <returns>一个新闻数据集,News是新闻,当然,List<XXXX>名称取决于你的数据源</returns>
protected List<News> GetNewsData(int num,int cateId,int isTop,int isCommend){
if (num < 0) num = 0;
List<News> result = new List<News>();
Expression<Func<News, bool>> expr = PredicateExtensionses.True<News>();
if (isPic) {
expr = expr.And(c => c.IsPic == 1);
}
if (cateId > 0) {
expr = expr.And(c => c.cateId == cateId);
}
if (isTop > -1) {
expr = expr.And(c => c.IsTop == isTop);
}
if (isCommend > -1) {
expr = expr.And(c => c.IsCommend == isCommend);
}
return nm.AllNews.Where(expr).OrderByDescending(c=>c.ID).Take(num).ToList();
}
复制代码 代码如下:
protected void Page_Load(object sender, EventArgs e)
{
DataBind();
}
复制代码 代码如下:
<asp:Repeater runat="server" DataSource='<%#GetNewsData(10,3548,-1,-1)%>'>
<ItemTemplate>
<%#Eval("Subject")%>
</ItemTemplate>
</asp:Repeater>
新闻热点
疑难解答
图片精选