Starter Site, every second search does not work

Hi there..

I am having some problems with the search from the starter site which seems rather odd. Every second time a search is run, the FreeTextDataSource.ExecuteSearch executes at a different point.

On the search that does return correctly the FreeTextDataSource.ExecuteSearch function from the control executes after the "On Pre Render" event on the Search.aspx page. On the second execution of the search, the FreeTextDataSource.ExecuteSearch function excutes after the "OnInitCompleted" event on the Search.aspx page.

Anyone else experienced this issue.. I have tried to trace where the FreeTextDataSource.ExecuteSearch function is being called from to no avail..

The order of execution I am seeing is as follows:
Search 1 (working search)
1. In
Search.aspx - OnPreRenderSearchDataSource.SearchPhrase is set
2.
In CatalogDataSource.cs - (IEnumerable ExecuteSelect) line 53. executes search
3.
In FreeTextSearchDataSource.cs -(CatalogItemsDataSet ExecuteSearch) line 85 executes search and returns CatalogItemsDataSet to ProductList Control.

Search 2 (same search returns nothing due to order of execution)
After Search.aspx "OnInitCompleted" event
1. In CatalogDataSource.cs - (IEnumerable ExecuteSelect) line 53.
2. In FreeTextSearchDataSource.cs - (CatalogItemsDataSet ExecuteSearch) line 85
3. In Search.aspx - OnPreRender executes where the SearchDataSource.SearchPhrase is set.
Any help would be greatly appreciated thanks

Ryan

[2815 byte] By [Ryan..] at [2008-1-10]
# 1
Problem solved.. I am not sure why this occurs but I will explain the solution..

It appears that in the starter site search.aspx you have something similar to the below

<div>
<asp:TextBox ID="Search" runat="server"></asp:TextBox>
<cc1:FreeTextSearchDataSource runat="server" ID="SearchDataSource" />
<siteStick out tongueroductList ID="ProductList" runat="server" DataSourceId="SearchDataSource"/>
</div>

Now basically for some unkown reason, the databinding occurs after different events on the second hit of the same page.. ? anyone have a clue as to why ?

In any case the simple solution was to change the HTML to the following

<div>
<asp:TextBox ID="Search" runat="server"></asp:TextBox>
<cc1:FreeTextSearchDataSource runat="server" ID="SearchDataSource" />
<siteStick out tongueroductList ID="ProductList" runat="server"/>
</div>

and change the codebehind to the following

protected override void OnPreRender(EventArgs e)
{
this.SearchTextBox.Text = this.SearchPhrase;
this.SearchDataSource.SearchPhrase = this.SearchPhrase;

this.ProductList.DataSourceId = this.SearchDataSource.ID;

base.OnPreRender(e);
}

And there you go.. Bob is your Auntie and the databinding occurs (which executes the search on binding from CatalogDataSource.cs) when you want it to occur which is after you set the searchphrase.

Hope this helps out anyone else out there who experienced the same issue..

Ryan.. at 2007-10-3 > top of Msdn Tech,Commerce Server,Commerce Server 2007...