I have a simple windows form with a datagridview and one csv file with 4 rows, the first being the headers.
The csv file looks like this:
I have read the code to populate the DataGridView1 from csv, and my code looks like this:
private DataSet ds = new DataSet();
private void button4_Click(object sender, EventArgs e)
ds = new DataSet();
dataGridView1.DataSource = ds.Tables.DefaultView;
String all_text = File.ReadAllText(@"c:\adataFile.csv").Split('\n');
int count_row = 0;
foreach (string row in all_text)
string data = row.Split(',');
if (count_row == 0)
foreach (string header in data)
I have tried to add another button and add ds.AcceptChanges(); but this does not work.
I know that when getting the data from SQL table I use sqlcommandbuilder, but i cannt seem to find any builder for CSV.
Please tell me how to commit the changes made in the DataGrid back to the csv file.