Try our conversational search powered by Generative AI!


Hi, I'm trying to write a search screen using the PageSearch control. The datasource is a collection of pages and I also use the SearchQuery parameter to filter on the datasource. The problem is that I still get all the pages from the page collection, no matter what I set the SearchQuery to. " maincatalog="<%# CurrentPage[ "MainCatalog" ] %>" pagelinkproperty="MainContainer" datasource="<%#GetDataSource()%>" searchquery="<%# txtKeywords.Text %>"> public PageDataCollection GetDataSource() { PageDataCollection colRetValue = new PageDataCollection(); PropertyCriteria pcJob = new PropertyCriteria(); pcJob.Type = PropertyDataType.String; pcJob.Name = "PageTypeName"; pcJob.Value = "GW_Job"; pcJob.Condition = CompareCondition.Equal; PropertyCriteriaCollection pccJob = new PropertyCriteriaCollection(); pccJob.Add(pcJob); PageDataCollection colJob = Global.EPDataFactory.FindPagesWithCriteria(Global.EPConfig.StartPage,pccJob); return colRetValue; } Thanks Danie
Jun 19, 2006 12:53
Daniel, I think the control behaves as intended. I believe the SearchQuery will not be used as a filter (as you assumed) - it will be used to perform a search of indexed strings in the database, returning only the pages that contain the search keywords. The way your code currently looks, it should retrieve a bunch of pages that fulfil the SearchQuery (based on pages below the starting point indicated by the MainContainer property, that have indexed string type properties). It will also return the full collection you retrieve and supply as DataSource - as there is no filter applied to those results. If your goal is to return only pages that contain the SearchQuery string and are ALSO of the GW_Job page type, you should be able to achieve that in at least two different ways: 1) Supply the PageTypeID="..." attribute in your PageSearch tag. (See the documentation for the PageSearch web control to see all available properties you can set.) 2) Add a filter event handler to your PageSearch control, filtering out any pages from the result that do not fulfil the PageType requirement. The code would be pretty similar to the code you are currently using to deliver a data source. (See the documentation of the FilterCompareTo class, for instance.)
Jun 19, 2006 14:42
Thanks Roger ! It works.
Jun 21, 2006 15:37
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.