C# Same DataSource + Multiple DataGridViews = Data Binding Issues?
Here's what I'm doing:
- I have (2) DataGridView controls
- DGV #1 is bound to the DataSet, DGV #2 is bound to a DataView of the SAME DataSet
Now, what I'm needing to accomplish here is this: When a user checks a boolean column on the original DGV, the second DGV shoul开发者_如何学Cd now display the newly checked row also.
The context is that the first DGV is a master list, and the second one is a "favorite" view of the first.
When I check the rows, the favorite column does NOT update. Do I need to use a DataAdapter to actually update the database, or can I operate directly on the DataSet (DataTable) -- or even with the Rows in the original DataGridView?
Figured this one out after a little more experimenting. Previously, I had been modifying the rows in the DataGridView, but to get them to propagate over into the "favorites" DataGridView, I had to call an AcceptChanges() method on the original DataSet. Like this:
dsInformation.AcceptChanges();
Evidently, this step is necessary for the newly toggled boolean field to update.
精彩评论