protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName == "GioHang") { DataTable dt; clsDatabase cls = new clsDatabase(); if (Session["GioHang"] == null) { dt = cls.GetDataTable(); } else { dt = (DataTable)Session["GioHang"]; } string strProductID, strProductName; int strPrice; int strNumber, strTotal; LinkButton lbt = new LinkButton(); Label lb = new Label(); //Tên sản phẩm lb = (Label)e.Item.FindControl("lbtProductName"); strProductName = lb.Text; //Mã sản phẩm strProductID = cls.LoadDuLieu("select ProductID from tbProduct where ProductName='" + strProductName + "'", 0); //Giá lb = (Label)e.Item.FindControl("lbPrice"); strPrice = int.Parse(lb.Text); //Số lượng strNumber = 1; //Tổng tiền strTotal = strNumber * strPrice; cls.DienVaoBang(dt, strProductID, strProductName, strPrice, strNumber, strTotal); Session["GioHang"] = dt; Response.Redirect("Cart.aspx"); } }