Solved

Shopping Cart DataSet Total Problem?

Posted on 2006-10-31
5
192 Views
Last Modified: 2013-11-29
I've been using a session dataset to hold products and a cookie to hold the total.

How can I make the dataset hold the total as well?

I'm using this code to add the total to a row:

 DataSet ds = (DataSet)Session["myds"];
        DataRow row = ds.Tables["tbl_Sales"].NewRow();
        row["col_Total"] = runningTotal.ToString();
        ds.Tables["tbl_Sales"].Rows.Add(row);

However, I never know which row will contain the actual accurate running total.
The row will vary according to the number of products added before the row.

I use this code to retrieve the total although "Rows[3 -10]" varies

        Amount.Text = ds.Tables["tbl_Sales"].Rows[3]["col_Total"].ToString();  

0
Comment
Question by:kvnsdr
  • 2
5 Comments
 
LVL 12

Expert Comment

by:craskin
ID: 17846533
you're probably better off keeping the total in a column using a SUM("moneycolumnname") AS Total in your SELECT statement that fills the dataset.
0
 
LVL 12

Expert Comment

by:craskin
ID: 17846540
or i guess you have some SP that gets the total for you, so i'm not sure why you want to put it in a row in your dataset.
0
 
LVL 1

Author Comment

by:kvnsdr
ID: 17847382
Is it common to use both session dataset and cookie for total?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 17849013
You can use a Session variable for both.  A cookie is commonly used to persist data between sessions, and since you aren't persisting the DataSet in a cookie, then it doesn't make any sense to persist the total.

Bob
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Businesses who process credit card payments have to adhere to PCI Compliance standards. Here’s why that’s important.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question