如何限制实体数据集中的记录来说明五条记录。我必须列出畅销书,但我想一次只展示五个?
它是否有我可以设置的行计数变量?
<asp:EntityDataSource ID="entybestseller" runat="server"
ConnectionString="name=CommerceEntities"
DefaultContainerName="CommerceEntities" AutoGenerateWhereClause=true
EnableFlattening="False"
EntitySetName="products">
<WhereParameters>
<asp:Parameter Name="isBestSeller" DefaultValue="True" DbType=Boolean />
</WhereParameters>
</asp:EntityDataSource>
<asp:ListView ID="lvbestseller" runat="server" DataSourceID="entybestseller">
<ItemTemplate>
<div class="s_item grid_2"> <a class="s_thumb" href="#"><img src="images/dummy/pic_5.jpg" title="Armani Acqua di Gioia" alt="Armani Acqua di Gioia" /></a>
<h3><a href="#"><%# Eval("title") %> </a></h3>
<p class="s_model"><%# Eval("title") %></p>
<p class="s_price s_promo_price"><span class="s_old_price"><span class="s_currency s_before"> <span><%# Eval("listprice") %></span><span class="s_currency s_before"></span><%# Eval("salesprice") %></p>
<a class="s_button_add_to_cart" href="addtocart.aspx?productid=<%# Eval("id") %>"><span class="s_icon_16"><span class="s_icon"></span>Add to Cart</span></a>
</div>
</ItemTemplate>
</asp:ListView>
答案 0 :(得分:0)
您可以为EntityDataSource添加选择属性
select="select top(5) title, id, listprice, salesprice"
这应该可以解决问题。