Data List - display only specific products on new page RRS feed

  • Question

  • User-559866590 posted


    I am developing a Visual C# and ASP.NET E-commerce web application. I have used a Datalist to populate information from my SQL database within Visual Studio. 

    I only want to display specific products on a new page after the button (btnAddToBasket) has been clicked.  

    For example, on my PlayStation web page, if the user clicks the button under the first product, then I only want the title, image, and price to be displayed on a new page for that specific product.

    Here is the ASP.NET code I have used for my data List:

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [Title], [ProductImage], [Price] FROM [PRODUCT] WHERE (([Console] = @Console) AND ([ProductType] = @ProductType))">
                <asp:Parameter DefaultValue="PlayStation 4" Name="Console" Type="String" />
                <asp:Parameter DefaultValue="Video Game" Name="ProductType" Type="String" />
            <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatColumns="2" RepeatDirection="Horizontal" Font-Bold="True" Font-Size="Large">
                    <div class="auto-style1" style="text-align: center; padding: 20px;">
                        <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
                        <br />
                        <asp:Image ID="Image3" runat="server" Height="200px" ImageUrl='<%# Eval("ProductImage") %>' Width="150px" />
                        <br />
                        £<asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' />
                        <br />
                        <br />
                        <asp:ImageButton ID="btnAddToBasket" runat="server" ImageUrl="~/images/shopping_basket_logo.jpg" />
                        <br />
                        <br />

    Does anyone have any suggestions on how I could resolve this issue?

    Kind Regards,


    Wednesday, March 15, 2017 11:40 AM


  • User-1838255255 posted

    Hi JonnyH91,

    According to your description, as far as I know, you want to show this product information in new page when you click this button. I think you could try the following steps:

    1. When you click this page, you could get the ID of the product.

    2. Then pass this ID as parameter in URL or other method.

    3. In the new page, you could use ado to select data from database through ID in page load event.

    4. show data in the new page.

    Best Regards,

    Eric Du

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 16, 2017 7:23 AM