mike Delvotti

mike Delvotti

  • NA
  • 262
  • 0

Only total fields with date value overdue

Dec 7 2011 12:07 PM
I'm counting the total in my datagrid fields, and it works fine in the code below. But i would like to get it a little slicker and only total Cells[6] if the date value in cells[3] is over 30 days old. is there any advice on how I could adapt the below code to do this?

            decimal total = 0;
            decimal price;
            foreach (DataGridViewRow row in jobcardsDataGridView1.Rows)
            {

                if (row.IsNewRow) break;
                Decimal.TryParse(row.Cells[6].Value.ToString(), out price);   
                total += price;
               
            }
            label1.Text = total.ToString("C");


Answers (2)