how to add multiple products to shopping cart

A

Adam

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>
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top