Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 386
  • Last Modified:

Trying to add a RowFilter to Datatable

Hi
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?

Thanks
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

0
hmcgeehan
Asked:
hmcgeehan
1 Solution
 
hiteshgoldeneyeCommented:
hi ,

Please refer this link
http://www.devnewsgroups.net/adonet/t3698-dataview-rowfilter-not-working.aspx

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

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now