Reverse (2-way) synchronization: DataGridView to Table (Database)
-
I am attempting to accomplish 2-way synch from a DataGridView to a table in my database. DGV to table is easy, but is there a "best practice" way to have the DGV automatically update to reflect any changes made to the database? I tried using a timer and perform a
TableAdapter.Fill(DataSet.SomeTable)
at regular intervals, but the problem with this approach is that it "clobbers" any edit in progress, and resets the selected row to the top. Preferably, I would avoid impacting the user so directly. Thank you... EDIT: Here is how I am synching DGV changes to the database:private void dgvSomeView_RowValidated(object sender, DataGridViewCellEventArgs e)
{
myTableAdapter.Update(myDataSet.MyTable);
} -
I am attempting to accomplish 2-way synch from a DataGridView to a table in my database. DGV to table is easy, but is there a "best practice" way to have the DGV automatically update to reflect any changes made to the database? I tried using a timer and perform a
TableAdapter.Fill(DataSet.SomeTable)
at regular intervals, but the problem with this approach is that it "clobbers" any edit in progress, and resets the selected row to the top. Preferably, I would avoid impacting the user so directly. Thank you... EDIT: Here is how I am synching DGV changes to the database:private void dgvSomeView_RowValidated(object sender, DataGridViewCellEventArgs e)
{
myTableAdapter.Update(myDataSet.MyTable);
}I think I found what I need: the SqlDependency class. Looking into it now...