store value for later use

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Scott

    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(DataTab le 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["SalesLastN ame"].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.





  • Scott

    #2
    Re: store value for later use

    I figured it out, thanks
    "Scott" <Scott@nospam.c omwrote in message
    news:u%23DWJBUe IHA.6136@TK2MSF TNGP03.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(DataTab le 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["SalesLastN ame"].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.
    >
    >
    >
    >
    >

    Comment

    Working...