protected void Page_Load(object sender, EventArgs e) { if (Session["user"] == null) { Session["prevpage"] = "ShoppingCart.aspx"; Response.Redirect("loginpage.aspx"); } DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name int customerId = (int)Session["userid"]; comm.CommandText = "SELECT ShoppingCart.customerId,ShoppingCart.productId,ShoppingCart.quantity,Product.productName,Product.productPrice,Product.productImagePath,Product.productCountryId,Product.categoryId,Product.vendorId,Product.productRating,Product.productShortDesc,Product.productLongDesc,Vendor.vendorName FROM dbo.ShoppingCart INNER JOIN dbo.Product ON ShoppingCart.productId=Product.productId INNER JOIN dbo.Vendor ON ShoppingCart.vendorId=Vendor.vendorId WHERE ShoppingCart.customerId="+customerId+";"; comm.CommandType = CommandType.Text; DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); DbDataReader reader = table.CreateDataReader(); string rows = null; int i = 0; Product[] productCart = new Product[20]; while (reader.Read()) { Product product = new Product(); product.setProductId(reader.GetInt32(1)); int custid = reader.GetInt32(0); product.setProductQuantity(reader.GetInt32(2)); product.setproductName(reader.GetString(3)); product.setProductPrice(reader.GetDouble(4)); product.setProductImagePath(reader.GetString(5)); product.setProductCountryId(reader.GetInt32(6)); product.setProductCategoryId(reader.GetInt32(7)); product.setProductVendorId(reader.GetInt32(8)); product.setProductRating(reader.GetInt32(9)); product.setProductShortDesc(reader.GetString(10)); product.setProductLongDesc(reader.GetString(11)); product.setproductVendorName(reader.GetString(12)); product.addProduct(product, productCart); rows += "<div class='prodtable'><input type=radio id=cart runat=server name=selproduct value=" + product.getProductId() + " /><img src=" + product.getProductImagePath() + " height=100 width=100 /><br /><b>Name: </b>" + product.getProductName() + " <br /><b>Vendor: </b>" + product.getProductVendorName() + " <br /><b>Quantity: </b>" + product.getProductQuantity() + "<br /><b>Price: </b>" + product.getProductPrice() + "<br /><br /></div>"; } if (productCart[0] != null) { rows += "<p style='margin-top:50px;font-size:60px;'>Total Price= " + productCart[0].calcTotalPrice(productCart); } /* <table width="80%" style="border: thin solid #000000; top:20%;"> <% Product[] productCart=(Product[])Session["productCart"]; %>> <% for (int i = 0; i < productCart.Length; i++) { if (productCart[i] != null) { %> <tr> <td> <img= id="img1" height="412" width="473" src="<%=productCart[i].getProductImagePath()%>"> </td> <td class="style1"> <ul> <li>Product Name: <%=productCart[i].getProductName()%></li> <li>Quantity:<%=productCart[i].getProductQuantity()%></li> <li>Rating:<%=productCart[i].getProductRating()%> </li> <li> </li> </ul> </td> </tr> <%} } %> TotalPrice= <%=productCart[0].calcTotalPrice(productCart) %> </table> */ if (Session["productCart"] == null) { Session["productCart"] = productCart; } tableproducts.InnerHtml = rows; }