I'm trying to create a refresh button to automatically refresh the data inside my datagridview after i have finish updating them.
However, my refresh button doesn't seem to work. The data displayed remains the same as the original one. It only gets updated after i manually end my windows app and rebuild it.
Here is my code:
private void button_refresh_Click(object sender, EventArgs e)
{
this.acuzioSecureStore_DatabaseXDataSet.AcceptChanges();
}
Please assist. thanks ^_^
Hey the solution above is good but when the above code is executed,the table disappears and is not seen. And if I execute
then whole table is created again.
The easiest way to handle this is to use a Binding Source object.
If your loading information into your DataGridView from an Access Database then your most likely storing the Data in a Dataset or DataTable.
Create a Binding Source object, and once you have populated your DataTable/Dataset, set the datasource for your Binding Source to your DataTable. Then set the Datasource from the DataGridView as the Binding Source object.
Doing this ensures that any changes in your datagridview or reflected in the DataTable and vice Versa. If you reload data into your DataTable it will reflect in the Data Grid Automatically.
All changes will now happen automatically.
I had a datagridview, bound to a table in an Entity Framework database:
It would never refresh despite two wasted days. I solved it with a simple workaround:
This is an ugly workaround, and friend explained me how it works - if I do just
dataGridView1.DataSource = database.table
, it will cache the table and use the cached data forever. The fact that each time we create a new dummy query, prevents .net from caching it.Please try this, it worked for me and let me know if you have any better option.
you Can Bind dataGridView On PageLoad or UserControl Load Event and After chage in grid view Call the Load Event
like
this.ucUsers_Load(null, null); // Windows From C#