protected void AddToCartButton_Click(object sender, EventArgs e) { // Retrieve ProductID from the query string string productId = Request.QueryString["ProductID"]; // Retrieve the selected product options string options = ""; foreach (Control cnt in attrPlaceHolder.Controls) { if (cnt is Label) { Label attrLabel = (Label)cnt; options += attrLabel.Text; } if (cnt is DropDownList) { DropDownList attrDropDown = (DropDownList)cnt; options += attrDropDown.Items[attrDropDown.SelectedIndex] + "; "; } } // Add the product to the shopping cart ShoppingCartAccess.AddItem(productId, options); }
// fires when an Add to Cart button is clicked protected void list_ItemCommand(object source, DataListCommandEventArgs e) { // The CommandArgument of the clicked Button contains the ProductID string productId = e.CommandArgument.ToString(); // Add the product to the shopping cart ShoppingCartAccess.AddItem(productId); }
// Add the product to cart protected void addToCartButton_Click(object sender, EventArgs e) { // Retrieve ProductID from the query string string productId = Request.QueryString["ProductID"]; // Add the product to the shopping cart ShoppingCartAccess.AddItem(productId); }
protected void AddToCart_Click(object sender, EventArgs e) { // Retrieve ProductID from the query string string productId = Request.QueryString["pid"]; // Retrieve the selected product options // string options = ""; /* foreach (Control cnt in attrPlaceHolder.Controls) * { * if (cnt is Label) * { * Label attrLabel = (Label)cnt; * options += attrLabel.Text; * } * if (cnt is DropDownList) * { * DropDownList attrDropDown = (DropDownList)cnt; * options += attrDropDown.Items[attrDropDown.SelectedIndex] + "; "; * } * }*/ // Add the product to the shopping cart ShoppingCartAccess.AddItem(productId); }