标签:
<asp:DataList ID="Good" runat="server" DataKeyField="ID" DataSourceID="SqlDataSource1" RepeatColumns="4">
<ItemTemplate>
<img src="../src/picture/<%#Eval("Image") %>" width="100px" height="100px" alt="<%#Eval("ImageName") %>" />
<br />
Name:
<asp:Label ID="NameLabel" runat="server" Text=‘<%# Eval("Name") %>‘ />
<br />
MarketPrice:
<asp:Label ID="MarketPriceLabel" runat="server"
Text=‘<%# Eval("MarketPrice") %>‘ />
<br />
Discount:
<asp:Label ID="DiscountLabel" runat="server" Text=‘<%# Eval("Discount") %>‘ />
<br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:connectstring %>"
SelectCommand="SELECT * FROM [tablename]"></asp:SqlDataSource>
参数解释:
RepeatColumns="4" //一行显示4个商品
DataKeyField="ID" //主键
ASP.NET(C#)——DataList控件——商品展示
标签:
原文地址:http://www.cnblogs.com/bluewhy/p/5106347.html