Click here to Skip to main content
13,000,002 members (49,318 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi All,

This is the first time i have ever posted in a forum.
I have been working on an eCommerce website for an assignment for quite a while now and cant work out how to calculate
total price = quantity * price
and then a grand total for all the products in the cart

i am using list view and have looked at many different codes on google but cant seem to get mine working.

This is what i have so far.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Cart = GetCart()
        If Not IsPostBack Then
        End If
    End Sub
    Private Function GetCart() As SortedList
        If Session("Cart") Is Nothing Then
            Session.Add("Cart", New SortedList)
        End If
        Return CType(Session("Cart"), SortedList)
    End Function
    Private Sub DisplayCart()
        Dim CartItem As CartItem
        Dim CartEntry As DictionaryEntry
        For Each CartEntry In Cart
            CartItem = CType(CartEntry.Value, CartItem)
    End Sub

    Protected Sub BtnDlt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnDlt.Click
        If lstCart.SelectedIndex > -1 And Cart.Count > 0 Then
        End If
    End Sub
 Dim myTotal As Decimal         'total cost
    Dim myTotalItems As Decimal    'total
    Dim intCount As Integer         'counter for
Sub Calculate()
        For intCount As Integer = 0 To lstCart.Items.Count - 1
            myTotal += CDec(lstCart.Items(intCount).Text)
        Next intCount
lblTotal.Text = lstCart.Items.Count

any help would be great, if i have forgotten to add a piece of code please let me know!

Posted 17-Nov-12 19:04pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170624.1 | Last Updated 18 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100