How can I select the year in each row

66 Views Asked by At

I am trying to get list of Dates of the year of manufacture for determining the age of vehicles. My column looks like this:

and my code looks like this

 partial void Reports_InitializeDataWorkspace(List<IDataService> saveChangesTo) {

        // year of manufacture
        var yom = InsuranceQuotations.SelectedItem.mYear;
        var bday = Convert.ToDateTime(yom);

        DateTime today = DateTime.Today;
        int age = today.Year - bday.Year;
        if (bday > today.AddYears(-age)) age--;

        Age = Convert.ToString(age);

    }

I can only select the fist date in the column. How could I loop through all dates in the column?

1

There are 1 best solutions below

0
paulpitchford On

You can loop through the Insurance quotes:

foreach (InsuaranceQuote item in InsuranceQuotes)
{
    var yom = item.mYear;
    ....
}

Note: I'm making some presumptions here. One is that your grid of insurance quotes are of type InsuranceQuote and two that the data collection on the screen is called InsuranceQuotes.