Если вы перебираете каждую строку DataGridView, вы можете использовать приведенный ниже метод для получения значения указанного столбца в определенной строке.
private T GetDataGridViewTextBoxValue<T>(int rowIndex, string columnName)
{
try
{
return (T)Convert.ChangeType(dataGridViewImport.Rows[rowIndex].Cells[columnName].Value, typeof(T));
}
catch (Exception e)
{
throw new InvalidOperationException(String.Format("Row : {0}, column : {1} could not be cast to {2}", rowIndex, columnName, typeof(T)), e);
}
}
И вы можете использовать этот метод следующим образом.
for(int i=0;i< ds2.Tables[0].Rows.Count(); i++)
{
var column1 = GetDataGridViewTextBoxValue<string>(i, "column1");
//Get the rest of the row values.
//In your DAL class you must have a Method that updates the row
//and then just pass in the values that you want.
}