Search code examples
c#asp.netdataview

How do I check for blank in DataView.RowFilter


Assuming I have a column called A and I want to check if A is null or blank, what is the proper way to check for this using the DataView's RowFilter:

DataTable dt = GetData();

DataView dv = new DataView(dt);

dv.RowFilter = "A IS NOT NULL OR A IS NOT ''";

The above doesn't seem to work though.


Solution

  • Are you tied to .net < 3.5? If not you can use linq to check the state of a column.

    Otherwise there is an Isnull(,) function like in T-SQL:

    dv.RowFilter = "Isnull(a,'') <> ''";