private static void GetListData(ref List <ListData> tempList, string tempProvinceValue) { //记录循环的次数 int count = 0; for (int j = 0; j < listData.Rows.Count; j++) { if (count < 3) { if (tempProvinceValue == "全国") { ListData row = new ListData(); row.CreateListData(tempProvinceValue, listData.Rows[j]); tempList.Add(row); count++; } else if (listData.Rows[j]["Province"] != null && listData.Rows[j]["Province"].ToString().Contains(tempProvinceValue)) { ListData row = new ListData(); row.CreateListData(tempProvinceValue, listData.Rows[j]); tempList.Add(row); count++; } } } }