Solved

Shopping Cart DataSet Total Problem?

Posted on 2006-10-31
5
189 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
Comment Utility
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
Comment Utility
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
Comment Utility
Is it common to use both session dataset and cookie for total?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Are you using email marketing software? If not, you're missing out on effortless marketing and the reaching of desired conversion rates through email marketing software.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now