I have a dataGridView bound to a table. On the same form as the DataGridView I have a few textboxes and a button to add new values to the database and want them displayed in the gridView too. Saving in the database works, just the new values are not shown in the gridView. I have tried the following:
this.Validate();
this.pBindingSource.EndEdit();
this.pTableAdapter.Update(this.DBDataSet);
pDataGridView.Refresh();
This didn't work. From my understanding the .Refresh method only redraws the GridView, so it should work after updating the tableAdapter, so I thought. But it doesn't.
Then I've tried:
this.pDataGridView.DataSource = null;
this.pDataGridView.DataSource = this.pBindingSource;
pDataGridView.Refresh();
which doesn't work either. Then tried to ResetBindings() for the binding source, which didn't work, and then I ran out of ideas.
How to refresh the DataGridView?
You can modify like
this.pDataGridView.DataSource = null;
this.pDataGridView.DataBind();
this.pDataGridView.DataSource = this.pBindingSource;
pDataGridView.DataBind();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With