DataView.RowFilter on Date null or not RRS feed

  • Question

  • I am trying to build two DataViews from a single Datatable. One grid should hold incomplete records (Null Date_Complete) and the other should have the completed records. The two statements below both return 100% of the records:
            dvEnroll_ToDO = New DataView(dtEnroll, "Date_Complete Is Null", "Resource_Name, Version", DataViewRowState.CurrentRows)
            dvEnroll_Done = New DataView(dtEnroll, "Date_Complete Is Not Null", "Resource_Name, Version", DataViewRowState.CurrentRows)


    Is there a way to compose a RowFilter to check for Null/Not Null dates?

    The IsNull method in help doesn't work - throws an error about date and string converstion.

    VB.Net, VS2005

    Tuesday, November 10, 2009 6:36 PM


  • Sounds odd that both returns all records. Hard to tell without more code.

    For example, this works:

                DataTable dt = new DataTable("Test");
                dt.Columns.Add("cId", typeof(int));
                dt.Columns.Add("cNull", typeof(DateTime));
                dt.Rows.Add(new object[] { 1, DateTime.Now });
                dt.Rows.Add(new object[] { 2, null });
                dt.Rows.Add(new object[] { 3, DateTime.Now });
                dt.Rows.Add(new object[] { 4, null });
                dt.Rows.Add(new object[] { 5, null });
                DataView dwNull = new DataView(dt, "cNull is null", "cId", DataViewRowState.CurrentRows);
                DataView dwNotNull = new DataView(dt, "cNull is not null", "cId", DataViewRowState.CurrentRows);
                Console.WriteLine("{0} - {1}", dwNull.RowFilter, dwNull.Count);
                Console.WriteLine("{0} - {1}", dwNotNull.RowFilter, dwNotNull.Count);

    Could you share more of your code?

    This posting is provided "AS IS" with no warranties.
    • Marked as answer by Yichun_Feng Tuesday, November 17, 2009 2:02 AM
    Wednesday, November 11, 2009 8:46 AM