65.9K
CodeProject is changing. Read more.
Home

Access the Data Rows Filtered by the BindingSource.Filter Property

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Mar 17, 2010

CPOL
viewsIcon

7682

I don't see any difficulty in finding the above solution, because I am using same functionality since long back. Here is my alternative code.Instead of creating a new DataView object, you can directly call the DataTable's DefaultView.sourceDataTable.DefaultView.RowFilter =...

I don't see any difficulty in finding the above solution, because I am using same functionality since long back. Here is my alternative code. Instead of creating a new DataView object, you can directly call the DataTable's DefaultView.
sourceDataTable.DefaultView.RowFilter = bindingSource.Filter;
DataTable destinationDataTable = sourceDataTable.DefaultView.ToTable();
My alternative code will reduce a bit overhead of creating another DataView object. Am I right? When our requirement is not updation of data, never create a new Data Table. Just create DataViews by setting RowFilter property as many as you want. This will reduce memory overhead on the system.