简体   繁体   中英

C# Same DataSource + Multiple DataGridViews = Data Binding Issues?

Here's what I'm doing:

  1. I have (2) DataGridView controls
  2. 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 should 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM