Trying to add a RowFilter to Datatable

Posted on 2009-12-24
Last Modified: 2012-05-08
I have a web part in Sharepoint 2007 that searches a Document Library.
I have a textbox so users can enter a Title and it works fine.

However I've just added a 'From' DateTimeControl and only wish to show documents which have a Publication Date greater than that.

However it seems to ignore my filter.

The Publication Date looks like this for example 26/7/2001

Any ideas?

string query = "<Query><OrderBy><FieldRef Name='Title' /></OrderBy></Query>";

            string rowFilter = "";

            //DataTable spDataTable = ExecuteCamlQuery("Media Coverage Admin - Categories", query);

            DataTable spDataTable = ExecuteCamlQuery(sharePointListName, query);

            //set the filter to cope with the search criteria - restrict the search to a specific category

            if (ddlCategories.SelectedValue == "")


                //DateTime theDT = new DateTime(2008, 1, 1);

                rowFilter = "Title LIKE '%" + tbSearch.Text + "%'";

                //"scheduled_completion_date < '" + System.DateTime.Now.ToString("MM/dd/yyyy") + "'"


            else //dont restrict to specific category


                rowFilter = "Title LIKE '%" + tbSearch.Text + "%' AND Category LIKE '%" + ddlCategories.SelectedValue + "%'";


            //if there's just a 'from date'

            if (dtcFromDate.IsDateEmpty == false)


                rowFilter += " AND Publication_x0020_Date >= '" + dtcFromDate.SelectedDate.ToString("dd/MM/yyyy") + "'";


spDataTable.DefaultView.RowFilter = rowFilter;

Open in new window

Question by:hmcgeehan
    1 Comment
    LVL 13

    Accepted Solution

    hi ,

    Please refer this link

    so in essence you cannot apply rowfilter to a datatable, it can be applied to a data view

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now