⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shopitem.aspx.cs

📁 ASP.NET2.0(C#篇)经典教程的源码...本源码很好的实现了购物车....编码规范和类的设计具有很好的借鉴性!
💻 CS
字号:
using System;
using System.Web;
using System.Web.UI.WebControls;
using Wrox.Commerce;

partial class ShopItem : System.Web.UI.Page
{
  protected void btnAddToCart_Click( object sender, System.Web.UI.ImageClickEventArgs e)
  {
    double Price = double.Parse(((Label)FormView1.FindControl("PriceLabel")).Text);
    string ProductName = ((Label)FormView1.FindControl("NameLabel")).Text;
    string PictureURL = ((Label)FormView1.FindControl("PictureUrlLabel")).Text;
    int ProductID = Convert.ToInt32(Request.QueryString["ProductID"]);

    // create the cart if it doesn't already exist
    if ( Profile.Cart == null )
      Profile.Cart = new Wrox.Commerce.ShoppingCart();

    // insert the item
    // if the item already exists in the cart, 1 will be added to the quantity

    Profile.Cart.Insert(ProductID, Price, 1, ProductName, PictureURL);

    // return back to the main shop page
    Server.Transfer("Shop.aspx");
  }
}

⌨️ 快捷键说明

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