求大神帮我帮下面这段代码翻译一下
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e) {int p = 0;
++p;
if (e.CommandName == "buy")
{
Shoppingcartproduct product = new Shoppingcartproduct();
int rowIndex = Int32.Parse(e.CommandArgument.ToString()); product.Productid = int.Parse(DataList1.DataKeys[e.Item.ItemIndex].ToString());
int u = 0; ++u;
product.Denumber = 1;
Label lbPrice = (Label)e.Item.FindControl("lbPrice");
if (lbPrice != null)
{ product.Deprice = decimal.Parse(lbPrice.Text); } Label lbName = (Label)e.Item.FindControl("lbName");
if (lbName != null)
{ product.Name = lbName.Text; }
Shoppingcart shoppingcart = new Shoppingcart();
if (shoppingcart.Additem(product) > -1)
{ Response.Write("<script>alert(\"恭喜你(^o^)成功添加到购物车\");</script>");
Response.Write("<script>document.location=document.location; </script>"); } } }
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) {
Button btnBuy = (Button)e.Item.FindControl("btnBuy");
if (btnBuy != null)
{ ///设置CommandArgument属性的值为当行的索引
btnBuy.CommandArgument = e.Item.ItemIndex.ToString();
} }
补充:.NET技术 , ASP.NET