public void DisplayTotals(string fiscalYear) { RetrieveFromDB rtrv = new RetrieveFromDB(); DataSet ds = rtrv.RetriveExpenduturesTotals(fiscalYear); 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"]; RetrieveFromDB rtrv = new RetrieveFromDB(); DataSet ds = rtrv.RetriveExpenduturesTotals(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); } }