private void buttonSave_Click(object sender, EventArgs e) { var items = new Dictionary <string, string>(); foreach (DataGridViewRow row in dataGridView.Rows) { if ((row.Cells[0].Value != null) && (row.Cells[0].Value.ToString() != "") && (row.Cells[1].Value != null) ) { items[row.Cells[0].Value.ToString()] = row.Cells[1].Value.ToString(); } } _reader.Save(items); }