// here 'm datatable from cache which is already stored, u can careate ur own datatable
DataTable NewGdt = (DataTable)HttpRuntime.Cache[cachekey];
int casesum = 0;
int pratesum = 0;
int appamtsum = 0;
DataTable dt = null;
DataTable StatusDT = null;
OleDbCommand cmd = null;
OleDbDataAdapter StatusAdpt = null;
DataRow[] rows = NewGdt.Rows;
dt = new DataTable();
dt.Columns.Add("SL No");
dt.Columns.Add("DISTRICT");
dt.Columns.Add("PKG_CATEGORY");
dt.Columns.Add("CASES");
dt.Columns.Add("AMT");
dt.Columns.Add("TOTALAPPAMOUNT");
foreach (DataRow dr in rows)
{
object[] row = dr.ItemArray;
dt.Rows.Add(row);
// here 'm getting sum on each row
casesum = casesum + Convert.ToInt32(dr["CASES"]);
pratesum = pratesum + Convert.ToInt32(dr["AMT"]);
appamtsum = appamtsum + Convert.ToInt32(dr["TOTALAPPAMOUNT"]);
}
DataRow newrow = dt.NewRow();
newrow["PKG_CATEGORY"] = "Total";
newrow["CASES"] = casesum.ToString();
newrow["AMT"] = pratesum.ToString();
newrow["TOTALAPPAMOUNT"] = appamtsum.ToString();
dt.Rows.Add(newrow);
/// 'm binding final table to gridview
ChildGridview.DataSource = dt;
ChildGridview.DataBind();
int count = ChildGridview.Rows.Count;
ChildGridview.Rows[count - 1].Font.Bold = true;
DataTable NewGdt = (DataTable)HttpRuntime.Cache[cachekey];
int casesum = 0;
int pratesum = 0;
int appamtsum = 0;
DataTable dt = null;
DataTable StatusDT = null;
OleDbCommand cmd = null;
OleDbDataAdapter StatusAdpt = null;
DataRow[] rows = NewGdt.Rows;
dt = new DataTable();
dt.Columns.Add("SL No");
dt.Columns.Add("DISTRICT");
dt.Columns.Add("PKG_CATEGORY");
dt.Columns.Add("CASES");
dt.Columns.Add("AMT");
dt.Columns.Add("TOTALAPPAMOUNT");
foreach (DataRow dr in rows)
{
object[] row = dr.ItemArray;
dt.Rows.Add(row);
// here 'm getting sum on each row
casesum = casesum + Convert.ToInt32(dr["CASES"]);
pratesum = pratesum + Convert.ToInt32(dr["AMT"]);
appamtsum = appamtsum + Convert.ToInt32(dr["TOTALAPPAMOUNT"]);
}
DataRow newrow = dt.NewRow();
newrow["PKG_CATEGORY"] = "Total";
newrow["CASES"] = casesum.ToString();
newrow["AMT"] = pratesum.ToString();
newrow["TOTALAPPAMOUNT"] = appamtsum.ToString();
dt.Rows.Add(newrow);
/// 'm binding final table to gridview
ChildGridview.DataSource = dt;
ChildGridview.DataBind();
int count = ChildGridview.Rows.Count;
ChildGridview.Rows[count - 1].Font.Bold = true;
No comments:
Post a Comment