简体   繁体   English

如何在每一行中选择年份

[英]How can I select the year in each row

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? 如何遍历列中的所有日期?

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 . 第一个是你的保险报价的网格是类型InsuranceQuote和两个在屏幕上的数据集合称为InsuranceQuotes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM