Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Shopping Cart DataSet Total Problem?

Posted on 2006-10-31
5
Medium Priority
?
204 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Often people are aiming at development of perfect Magento websites. Though, it is easier said than done. You know what’s much easier? To ruin everything. It can be done in seconds. Many of us experimented with design, tried to change some values dir…
Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
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…

618 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