No Job Description Total MD Used MD Balance MD 1 Blk-66A 1.1 1st story 3.00 3.00 0.00 2 Blk-66A 2.1 Basement 4.00 2.00 2.00 2.2 Basement 3.00 1.00 2.00 ---------------------------------------------- Total
<pre>No Job Description Total MD Used MD Balance MD 1 Blk-66A 1.1 1st story 3.00 3.00 0.00 2 Blk-66A 2.1 Basement 4.00 2.00 2.00 2.2 Basement 3.00 1.00 2.00 ---------------------------------------------- Total 10.00 5.00 4.00
Decimal total = 0; ; leaveGrid.FooterRow.Cells[0].Text = "Total"; leaveGrid.FooterRow.Cells[1].Font.Bold = true; leaveGrid.FooterRow.Cells[1].HorizontalAlign = HorizontalAlign.Left; for (int k = 2; k < firstTable.Columns.Count; k++) { total = firstTable.AsEnumerable().Where(row => row.Field<String>(firstTable.Columns[k].ToString()) != "").Sum(row => row.Field<Decimal>(firstTable.Columns[k].ToString())); leaveGrid.FooterRow.Cells[k].Text = total.ToString(); leaveGrid.FooterRow.Cells[k].Font.Bold = true; leaveGrid.FooterRow.BackColor = System.Drawing.Color.Beige; }
DataTable
DataSource
DataGridView
total = firstTable.AsEnumerable().Where(row => !DBNull.Value.Equals(row[k])).Sum(row => Convert.ToDecimal(row[k]));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)