public void LoadCartRecommendations() { // display product recommendations DataTable table = ShoppingCartAccess.GetRecommendations(); if (table.Rows.Count > 0) { list.ShowHeader = true; list.DataSource = table; list.DataBind(); } }
protected void Page_PreRender(object sender, EventArgs e) { // Get the currently loaded page string currentLocation = Request.AppRelativeCurrentExecutionFilePath; // If we're in Product.aspx... if (currentLocation == "~/Product.aspx") { // get the product ID string productId = Request.QueryString["ProductID"]; // get product recommendations DataTable table; // display recommendations table = CatalogAccess.GetRecommendations(productId); list.DataSource = table; list.DataBind(); // display header if (table.Rows.Count > 0) { recommendationsHeader.Text = "Customers who bought this product also bought:"; } else { recommendationsHeader.Text = ""; } } // If we're in ShoppingCart.aspx... else if (currentLocation == "~/ShoppingCart.aspx") { // get product recommendations DataTable table; // display recommendations table = ShoppingCartAccess.GetRecommendations(); list.DataSource = table; list.DataBind(); // display header if (table.Rows.Count > 0) { recommendationsHeader.Text = "Customers who bought these products also bought:"; } else { recommendationsHeader.Text = ""; } } }