how to add multiple products to shopping cart

Discussion in 'ASP .Net Datagrid Control' started by Adam, Sep 13, 2003.

  1. Adam

    Adam Guest

    Hi All,

    I'm developing a shopping cart based on IBuyspy StoreVB which could let
    customer add multiple products from productlist.aspx (datagrid with checkbox
    column) into shopping cart, but I have problems to write code to let button
    "addsaveitems" to add selected items into shopping cart, is there any can
    help me???

    <script runat="server">

    Sub Submit_Click (sender As Object, e As System.EventArgs)

    Dim productCatalogue As IBuySpy.ProductsDB = New IBuySpy.ProductsDB()

    ' Iterate through all rows within shopping cart list
    Dim i As Integer
    For i = 0 To Datagrid1.Items.Count - 1

    ' Obtain references to row's controls
    Dim save As CheckBox = CType(Datagrid1.Items(i).FindControl("Save"),

    ' If the checked box field is checked
    If save.Checked = True then
    Dim cart As IBuySpy.ShoppingCartDB = New IBuySpy.ShoppingCartDB()

    ' Obtain current user's shopping cart ID
    Dim cartId As String = cart.GetShoppingCartId()

    ' Save selected Items to Cart, where the problem is: I don't how to write
    the code to add checked items from datagrid to shopping card'
    cart.AddItem(cartId, CInt(Request.Params("ProductID")), 1)

    End If
    End Sub

    <asp:DataGrid id="Datagrid1" runat="server" AllowCustomPaging=" ......... >

    <ItemStyle forecolor="#330099" cssclass="CartListItem"
    <asp:TemplateColumn HeaderText="Product Image" FooterText="Product Image">
    <a href='ProductDetails.aspx?productID=<%#
    DataBinder.Eval(Container.DataItem, "ProductID") %>'><img src='<%#
    DataBinder.Eval(Container.DataItem, "ProductImage",
    "/StoreVB/ProductImages/thumbs/{0}") %>' /><img src="images/enlarge.gif"
    <asp:BoundColumn DataField="ProductID" HeaderText="Item#"
    FooterText="Prdocut ID"></asp:BoundColumn>
    <asp:BoundColumn DataField="ModelName" HeaderText="Model Name"
    FooterText="Model Name"></asp:BoundColumn>
    <asp:BoundColumn DataField="UnitCost" HeaderText="Unit Price"
    FooterText="Unit Price"></asp:BoundColumn>
    <asp:HyperLinkColumn Text="Inquiry Now!" Target="_self" HeaderText="Add to
    Cart" FooterText="Add to inquiry basket" DataNavigateUrlField="ProductID"
    DataNavigateUrlFormatString="AddToCart.aspx?ProductID={0}" />
    <asp:TemplateColumn HeaderText="Save to Cart" FooterText="Save to Cart">
    <asp:CheckBox id="Save" runat="server" />
    <asp:Button id="Submit" onclick="Submit_Click" runat="server" text="Submit
    to Cart" forecolor="LemonChiffon" font-bold="True" backcolor="#C00000"

    Adam, Sep 13, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.