store value for later use

S

Scott

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top