I am working on a system that currently has a rather sophisticated function that returns a DataTable, which then binds to a GUI control in ASP.NET WebForm.
My problem is that I need to filter the returned data - some data that is returned should not be displayed to the user.
I know about DataTable.select (), but this is not quite what I need. First, it returns an array of DataRows, and I need a DataTable, so I can bind it to a GUI control. But more importantly, the filtering I need to do is not something that can easily be expressed with a simple expression. I have an array of elements that I do not want to display, and I need to compare each element from the DataTable with this array.
What I can do, of course, is to create a new DataTable, read everything from the original, add a new one that fits, and then bind a new one to the GUI control. But it somehow seems wrong. In this case, the number of elements in the original DataTable is unlikely to be enough to copy them all into memory, which will cause too many problems, but I wonder if there is another way.
Does the .NET DataTable have functionality that would allow me to filter through a callback function?
source
share