954,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to Total the Values from a Datalist into a Label

Team -

I hope you can give me a hand here. I am working on a shopping cart type site which displays products in a datalist. I need to find a way to add up all the products and place that total in a label outside of the datalist.

Also, any opinions if I should use a datalist or a repeater control are also welcome! (can't use datagridview).

Thank you all for your help.

Dewayne

bluem1
Newbie Poster
24 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

I don't know the type of data source you have used.

if DataTable/DataSet then code should be,

int total=0;
 foreach(DataRow r in dt.Rows)
  {
    total = total +  ((int)r["total"]);
  }
 ...
__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: