shoppingcart.ascx

来自「ASP.NET2.0(C#篇)经典教程的源码...本源码很好的实现了购物车...」· ASCX 代码 · 共 38 行

ASCX
38
字号
<%@ Control Language="C#" AutoEventWireup="true" codefile="ShoppingCart.ascx.cs" Inherits="ShoppingCartControl" %>

<%@ import Namespace="Wrox.Commerce" %>

    <!--
    This grid isn't bound using a data source control, so we
    have to provide the two way binding ourselves, by handling the events
    -->
    <asp:GridView ID="CartGrid" Runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID"
        OnRowEditing="CartGrid_RowEditing" OnRowUpdating="CartGrid_RowUpdating"
        OnRowDeleting="CartGrid_RowDeleting" OnRowCancelingEdit="CartGrid_RowCancelingEdit">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:Image id="ProductImage" Runat="server" ImageUrl='<%# Eval("ProductImageURL", "~/ProductImages/thumb_{0}")%>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="ProductName" HeaderText="Product" ReadOnly="True" />
            <asp:BoundField DataField="Quantity" HeaderText="Quantity" />
            <asp:BoundField DataField="Price" HeaderText="Price" DataFormatString="{0:c}" ReadOnly="True" />
            <asp:BoundField DataField="LineTotal" HeaderText="Total" DataFormatString="{0:c}" ReadOnly="True" />
            <asp:CommandField ShowEditButton="True" ShowDeleteButton="true"></asp:CommandField>
        </Columns>
        <EmptyDataTemplate>
            There is nothing in your shopping cart. You can buy items from the 
            <a href="shop.aspx">Shop</a>.
        </EmptyDataTemplate>
    </asp:GridView>

    <br />

    <asp:Panel ID="DiscountPanel" Runat="server" Visible="false">
        <asp:Label ID="SubTotalLabel" runat="server" /><br />
        <asp:Label ID="MemberDiscount" Runat="server" />
    </asp:Panel>
    <br />
    <asp:Label ID="TotalLabel" Runat="server" />

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?