📄 shopitem.aspx.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 + -