Eric
Mon Oct 27 16:47:24 CST 2003
Loop though all the rows and add the values up:
int total = 0;
DataTable dt = null;
DataSet ds = dgorders.DataSource as DataSet;
if (ds != null)
dt = ds.Tables["table name goes here if bound to a dataset"];
if (dt == null)
dt = dgorders.DataSource as DataTable;
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
total += int.Parse(dt.Rows[i]["qty"].ToString());
}
}
return total;
If the field is already an int type you could directly cast it to int:
total += (int)(dt.Rows[i]["qty"]);
HTH;
Eric Cadwell
http://www.origincontrols.com