我想顯示在我的網頁上的特色表中的前3名產品從同一個數據源,這是從SQL拉所有行,然後所有行可以在另一個asp.net中找到中繼器。如何限制限制asp.repater只綁定前兩行
ASP.net
<asp:Repeater ID="FeaturedProduct" runat="server">
<ItemTemplate>
<tr>
<td><%# Eval("ProductName")%></td>
<td><%# Eval("Price")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
SQL數據源
<asp:SqlDataSource DataSourceMode="DataSet" ID="ProductPics" runat="server" ConnectionString="<%$ ConnectionStrings:PIConnectionString1 %>"
SelectCommand="Select ProductName, Price from Products where ProdImageId = @ProdId">
<SelectParameters>
<asp:RouteParameter Name="ProdId" DbType="Int32" RouteKey="ProdId" />
</SelectParameters>
</asp:SqlDataSource >
C#
FeaturedProduct.DataSourceID = "PriceComparison";
更新 我已完成前3行的限制datasouce,但現在eval綁定不起作用。那麼我怎樣才能將數據綁定到html中的元素。
var mycollection = ProductPics.SelectCommand;
FeaturedProduct.DataSource = mycollection.Take(3);
FeaturedProduct.DataBind();
我們在談論哪個數據庫系統? – Alexander
SQL Server 2008. Alex – Vicky
So Alex,我想綁定兩個HTML表格與相同的數據源,並希望在摺疊上方的表格上顯示2-3條記錄作爲特色,並鏈接查看所有(這將指向另一個表所有行)低於網頁的摺疊。 – Vicky