这段代码的目标是让每个DataGridViewRow将包含数据作为List中的单独元素。问题是还记录了空行。
foreach (DataGridViewRow row in dataGridView1.Rows)
{
List<int> rowtemp = new List<int>();
foreach (DataGridViewCell cell in row.Cells)
{
if (cell.Value!=null && cell.Value.ToString().Length > 0)//empty cells are passing this check. Why?
{
if (Int32.TryParse(cell.Value.ToString(), out v) == true)
rowtemp.Add(v);
else
ErrorLog("Value must be single number in each cell. It is: " + cell.Value.ToString());
}
}
xmlParse(rowtemp);
}