操作回顾
以和Product Catalog页面基本相同的方法调整Product Item页面主要的区别是没有查看所有的商品而只希望查看某个商品的详情如果查看源代码将再次看到它由SqlDataSource和DataList控件组成
<form id=form runat=server>
<div>
<asp:SqlDataSource ID=SqlDataSource runat=server ConnectionString=<%$ ConnectionStrings:WroxUnitedConnectionString %>
SelectCommand=SELECT DISTINCT [ProductID] [Name] [Description] [Price] [PictureURL] FROM [Products] WHERE ([ProductID] = @ProductID)>
<SelectParameters>
<asp:QueryStringParameter Name=ProductID QueryStringField=ProductID Type=Int />
</SelectParameters>
</asp:SqlDataSource>
</div>
<asp:DataList ID=DataList runat=server DataKeyField=ProductID DataSourceID=SqlDataSource>
<ItemTemplate>
<asp:Label Visible=false Text=<%# Eval(PictureURL) %> runat=server ID=PictureUrlLabel />
<asp:Image ID=Image runat=server ImageUrl=<%# Eval(PictureURL ProductImages\{}) %> /><br />
<asp:Label ID=NameLabel runat=server Text=<%# Eval(Name) %>></asp:Label><br />
<asp:Label ID=DescriptionLabel runat=server Text=<%# Eval(Description) %>>
</asp:Label><br />
<asp:Label ID=PriceLabel runat=server Text=<%# Eval(Price {:##}) %>></asp:Label><br />
<br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:ImageButton ID=btnAddToCart runat=server OnClick=ImageButton_Click ImageUrl=~/Images/AddToCartgif /><br />
<asp:HyperLink ID=HyperLink runat=server NavigateUrl=~/WroxShopaspx>Return to Shop</asp:HyperLink>
</form>
[] [] [] []