0

I still can't wrap my head around this. I've read several posts like:

New DataView vs. DefaultView of a DataTable

I have a DataTable that I bound to a DataGridView. I needed a fast filter capability so I created a DataView and bound that to the DataGridview (with some filters applied).

So now I'm looking at a filtered version of my original DataTable in the datagridview. With me?

Next, it adds a column with some data for each visible row. I used a 'For each row in DataGridView' to do this. When I remove my filters in the dataview (to show all rows). All the data I added in the columns disappears.

What is the proper way to interact with this data? If I add columns/data to the datagridview, do I have to apply that somehow to the dataview?

Please help clarify this concept.

Much appreciated.

Extra Info Here is my flow

  1. Fill DataTable
  2. Create DataView from DataTable
  3. Bind DataView to DataGridview
  4. User initiates filter on DataView based on critera
  5. User adds information to DataGridView (columns and data)
  6. User removes filter from DataView
  7. All original rows are now shown in the datagridview but the new column data is missing (columns are there but no data)
Community
  • 1
  • 1
malt_man
  • 403
  • 1
  • 6
  • 21
  • User adds columns and data, so this means that your users can create new columns in the datagridview ? Is this really so ? – GuidoG Sep 16 '15 at 07:41
  • The user clicks a button that compares the current table with another, the code adds a column with the matched data from the other table. – malt_man Sep 18 '15 at 14:55
  • I see, this is gonna be difficult because the columns you have added are not part of the DataSource for the DataGridView. So when you remove your filters the DataGridView will ask its DataSource for data and that data has no knowledge of these new columns. You will have add the new columns to the DataSource to get this done – GuidoG Sep 18 '15 at 15:12

0 Answers0