would like to filter a datatable but in reverse

1

I found these examples:

link

dt is a DataTable and it has data, but there are some data that are null, I would like to filter the rows that contain such null data.

number is one of the columns.

I would like to filter and keep all the datatable rows that are not null

    dt.DefaultView.RowFilter = "numero <> 'null Column'"; (1)
    dt = dt.DefaultView.ToTable();

but I get this error when I try to execute (1)

Unhandled exception of type 'System.Data.EvaluateException' in System.Data.dll

Additional information: The operation '< >' can not be performed in System.Double and System.String.

There is a way to filter and keep the rows that are null

    dt.DefaultView.RowFilter = "[numero] is null";
    dt = dt.DefaultView.ToTable();

but I want the opposite, that is, NOT to stay with those who are null

    
asked by Hugo Mariño 22.06.2016 в 23:44
source

1 answer

0

You should use IS NOT NULL instead of IS NULL:

        dt.DefaultView.RowFilter = "numero IS NOT NULL";
    
answered by 22.06.2016 / 23:54
source