473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

store value for later use

In my web app I'm creating a datatable to show my out in a grid. I have a
row that has totals within my datatable. How can I store that total to use
in another section of code?

my datatable looks like this

dtFinal = new DataTable();
ds = GetSalesValues();

dc = new DataColumn;
dc.ColumnName = "Sales";
dt.Columns.Add(dc);

foreach(DataTable dt in ds.Tables)
{
foreach(DataRow drResults in dt.Rows)
{
dr = dt.NewRow();
totalIncome = Convert.ToInt32(drResults["Sales"]) -
Convert.ToInt32(drResults["Expenses"]);
dr["Name"] = drResults["SalesLastName"].ToString();
dr["Sales Year"] = drResults["Year"];
dr["Total Income"] = totalIncome;
}
}

now this gets the income for each year and I have it showing within my grid.
How can I keep the totalincome value for each year (row within the
datatable) so I can use it within another function?

So if I have 25,000 for 2007 and 22,500 for 2006, I want to store both
totals so I can use them for another calc in another routine in my app.

Feb 27 '08 #1
1 1253
I figured it out, thanks
"Scott" <Sc***@nospam.comwrote in message
news:u%****************@TK2MSFTNGP03.phx.gbl...
In my web app I'm creating a datatable to show my out in a grid. I have a
row that has totals within my datatable. How can I store that total to use
in another section of code?

my datatable looks like this

dtFinal = new DataTable();
ds = GetSalesValues();

dc = new DataColumn;
dc.ColumnName = "Sales";
dt.Columns.Add(dc);

foreach(DataTable dt in ds.Tables)
{
foreach(DataRow drResults in dt.Rows)
{
dr = dt.NewRow();
totalIncome = Convert.ToInt32(drResults["Sales"]) -
Convert.ToInt32(drResults["Expenses"]);
dr["Name"] = drResults["SalesLastName"].ToString();
dr["Sales Year"] = drResults["Year"];
dr["Total Income"] = totalIncome;
}
}

now this gets the income for each year and I have it showing within my
grid. How can I keep the totalincome value for each year (row within the
datatable) so I can use it within another function?

So if I have 25,000 for 2007 and 22,500 for 2006, I want to store both
totals so I can use them for another calc in another routine in my app.



Feb 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bryan Lynn | last post by:
Is there any way to store a GUID value as a property on a file/folder? When my app creates new files/folders, I'd like to store a GUID as a custom property on the file/folder. This way, when the...
2
by: Peter Rilling | last post by:
How does Windows store passwords that it uses? For instance, when you install a service, you can provide it the username and password. This information is stored somehow so that at a later date...
4
by: iwdu15 | last post by:
quick question for anyone who can help...im trying to mak a program that will take an entered username and store a list of teams they chose from a list and save that, to be called later. does...
6
by: Mike Hoff | last post by:
I am trying to write a class that will store info about database fields for building UPDATE / INSERT commands later on. I cannot seem to get the sytax correct to pass and store the data type of...
0
by: Harley | last post by:
I am trying to write a personal app to keep a bank balance and history. The problem I'm haveing is finding a decent way to store the data on a pocketpc under .net compact framewok useing vb.net....
1
by: Imry | last post by:
I have an application that enables the user to change the color of the form (pretty simple). I want that color to be saved to a DB when the form is closed. Then, when the form is opened again, I...
12
by: dbuchanan | last post by:
I am designing a table to contain a field to stores a value that must indicate none, one, or many choices. The form will have a group box with checkboxes (multi-choice) You see the records in...
11
by: mwebel | last post by:
Hi, i had this problem before (posted here and solved it then) now i have the same problem but more complicated and general... basically i want to store the adress of a istream in a char* among...
7
by: loial | last post by:
I need to store a list of variable names in a dictionary or list. I then later need to retrieve the names of the variables and get the values from the named variables. The named variables will...
70
mideastgirl
by: mideastgirl | last post by:
I have recently been working on a website for an honors association, and have a lot of difficulty but have found help from those on this site. I would like to see if I can get some more help on a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.