【问题标题】:How i can display top 3 record我如何显示前 3 条记录
【发布时间】:2017-03-07 07:49:35
【问题描述】:

我在 ASP.NET 网站中有一个中继器,我只想显示 3 条记录 中继器:

<asp:Repeater ID="repNews" runat="server" DataSourceID="EntityDataSource1">
    <ItemTemplate>
        <ul>
         <li><a href='<%# Eval("news_link")%>' > <asp:Label ID="lblNews" runat="server" Text='<%# Eval("news_title")%>' /></a></li> 
      </ul>
    </ItemTemplate>

和实体模型

 </asp:Repeater>  
  <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=AGIP_dbEntities" DefaultContainerName="AGIP_dbEntities" EnableFlattening="False" EntitySetName="tbl_news" >
  </asp:EntityDataSource>

【问题讨论】:

标签: asp.net vb.net entity-framework repeater


【解决方案1】:

谢谢大家,但我试试这个和这个工作

Select="top(2) it.news_title,it.news_link"

在实体数据源中添加

会是这样的

<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=AGIP_dbEntities" DefaultContainerName="AGIP_dbEntities" EnableFlattening="False" EntitySetName="tbl_news"  Select="top(2) it.news_title,it.news_link">
  </asp:EntityDataSource>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-15
    • 1970-01-01
    • 1970-01-01
    • 2021-09-27
    • 2015-09-05
    • 2012-12-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多