Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2006, 11:56 AM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem in getting total

hi all,

i facing a problem, described belwo in detail
hope someone can can help me in resolving this

i am displaying a datagrid with some informations, say productid, unitprice,quantity.
i have a label which displays the subtotal of all the items displayed.
the datagrid has an option for delete.
if i delete one product, the subtotal is not changing.
can anyone please say, where is the problem in my code

page_load( )
 If Not Page.IsPostBack Then
            bindgrid()
        End If

 Dim total As Decimal = 0

            Try
                For Each dgi As DataGridItem In DataGrid1.Items
                    If dgi.ItemType = ListItemType.Item OrElse dgi.ItemType = ListItemType.AlternatingItem Then


                        Dim quantity As Integer = Integer.Parse(dgi.Cells(3).Text)
                        Dim unitprice As Decimal = Decimal.Parse(dgi.Cells(2).Text)
                        total = total + (unitprice * quantity)

                    End If
                Next
                     Catch ex As Exception

            End Try
            lblsubtotal.Text = total.ToString("c")


                       lbltax.Text = (CInt(lblsubtotal.Text) * 0.06).ToString("c")
            lblship.Text = (CInt(lblsubtotal.Text) * 0.15).ToString("c")
            lblgrand.Text = (CInt(lblsubtotal.Text.ToString) + (lbltax.Text.ToString) + (lblship.Text.ToString)).ToString("c")


end sub

thanks

 
Old December 12th, 2006, 12:05 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I dont see where you are facilitating the deletion of items from your cart.

Here is the psuedo code for what i would do

Handle OnItemDeleted
--Remove indexed item from the cart
--Calcualte the new total in SQL
--Rebind the grid

That is just what i would do. In any case what i think your poblem is is that when you delete an item, you are still working with the grid that has that item in its cells, even though you have removed it from the backend table. You should delete from your database rebind your grid then loop through for your new total.

hth

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old December 12th, 2006, 12:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there...
how are you deleting the items??

maybe the load is not executing again after the delete???

HTH

Gonzalo
 
Old December 12th, 2006, 12:13 PM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks Mr.Parson, your idea got worked

 
Old December 12th, 2006, 12:37 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Glad it worked out for you.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem With Total in the Shopping Cart learningASP.Net BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 October 27th, 2007 09:33 AM
Getting the Total northwind XSLT 1 April 26th, 2007 03:40 AM
Problem in calculating total sales in MDX query jaee SQL Server 2000 0 March 9th, 2007 11:10 AM
Sub Total Rjh Reporting Services 0 June 21st, 2006 04:11 PM
XSLT sub total problem sundar_revathi XSLT 2 October 7th, 2004 03:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.