2
Answers

Only total fields with date value overdue

mike Delvotti

mike Delvotti

13y
1.3k
1
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)