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???

    Productlist.aspx:
    <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"),
    CheckBox)

    ' 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
    Response.Redirect("ShoppingCart.aspx")
    Next
    End Sub
    </script>



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

    <ItemStyle forecolor="#330099" cssclass="CartListItem"
    backcolor="White"></ItemStyle>
    <Columns>
    <asp:TemplateColumn HeaderText="Product Image" FooterText="Product Image">
    <ItemTemplate>
    <center>
    <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"
    /></a>
    </center>
    </ItemTemplate>
    </asp:TemplateColumn>
    <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">
    <ItemTemplate>
    <center>
    <asp:CheckBox id="Save" runat="server" />
    </center>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>
    <asp:Button id="Submit" onclick="Submit_Click" runat="server" text="Submit
    to Cart" forecolor="LemonChiffon" font-bold="True" backcolor="#C00000"
    bordercolor="#FFC0C0"></asp:Button>

    </body>
    </html>
     
    Adam, Sep 13, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GeorgeF

    Perl Shopping Cart Scripts

    GeorgeF, May 21, 2005, in forum: Perl
    Replies:
    1
    Views:
    3,297
    James T
    May 22, 2005
  2. Bruce W...1

    Secure shopping cart example?

    Bruce W...1, Aug 26, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    640
    Bruce W...1
    Aug 27, 2003
  3. Mark Fox

    Shopping Cart Component Suggestions

    Mark Fox, Nov 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    398
    Jacob Yang [MSFT]
    Nov 4, 2003
  4. John Dalberg
    Replies:
    0
    Views:
    318
    John Dalberg
    Apr 30, 2004
  5. Infused
    Replies:
    0
    Views:
    127
    Infused
    Aug 2, 2007
Loading...

Share This Page