?
Solved

Shopping Cart DataSet Total Problem?

Posted on 2006-10-31
5
Medium Priority
?
201 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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:
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.
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 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