Solved

Shopping Cart DataSet Total Problem?

Posted on 2006-10-31
5
193 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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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 tutorial demonstrates a quick way of adding group price to multiple Magento products.

734 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