hmcgeehan
asked on
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
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;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.