In my C# winforms project I have a DataGridView which is displaying a View of two SQL tables. Is there a workaround for Updating the View from the DataGridView.

Using a Save button on my form,
At first I assumed I could update the View like this:

this.DataSet.EndInit();
this.ViewTableAdapter.Update(this.DataSet.View);

Did not work so I tried updating the tables separately and still was not able to update:

this.DataSet.EndInit();
this.TableOneTableAdapter.Update(this.DataSet.TableOne);
this.TableTwoTableAdapter.Update(this.DataSet.TableTwo);

I have another form where a DataGridView is displaying just one Table and using the following works fine when Updating:

this.DataSet.EndInit();
this.TableTableAdapter.Update(this.DataSet.Table);

No, if you want to update view, you will have to re-populate dgv.
You can do it on 2 ways:
1. create dataTable and bind it to the dataSource of dgv
2. crete dataTable and populate dgv manually (column by column, row by row)

The best way of populating dgv is to fill dataTable with sql adapter (in sql query), and then use these data in dataTable.

Hope it helps,
happy coding
If you need any asistance, let me know, and please specify exactly what you need and if possible give us some of your code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.