public void DisplayTotals(string fiscalYear) { StoredProcedures sp = new StoredProcedures(); DataSet ds = sp.RetriveExpendituresTotals(fiscalYear); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i][1].ToString() == String.Empty) { ds.Tables[0].Rows[i].Delete(); } } if (ds.Tables[0].Rows.Count != 0) { ExpendutersTotalsPanel.Visible = true; ExpendutersTotalsGridView.DataSource = ds; ExpendutersTotalsGridView.DataBind(); } }
protected void ExpendutersTotalsGridView_OnRowDataBound(Object sender, GridViewRowEventArgs e) { String fiscalYear = (String)Session["FiscalYear"]; StoredProcedures sp = new StoredProcedures(); DataSet ds = sp.RetriveExpendituresTotals(fiscalYear); Double total = 0; foreach (DataRow row in ds.Tables[0].Rows) { if (row[1].ToString() != "") { total = Double.Parse(row[1].ToString()) + total; } } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[0].Text = "Total"; e.Row.Cells[1].Text = String.Format("{0:C}", total); } }