SearchDataSource PageLink as PropertyParameter works but hardcoding PageLink attribute does not.

Vote:
 

I hope someone can help really quickly with this one.

I have a simple search results page, copied from the AlloyTech Example Templates. Here is my Datasource control:

    <EPiServer:SearchDataSource ID="SearchDataSource" runat="server">
        <SelectParameters>
            <EPiServer:PropertyParameter Name="PageLink" PropertyName="SearchRoot" />
            <asp:controlparameter name="SearchQuery" controlid="SearchText" propertyname="Text"/>
            <asp:controlparameter name="OnlyWholeWords" controlid="SearchOnlyWholeWords" propertyname="Checked"/>
        </SelectParameters>
    </EPiServer:SearchDataSource>

I want to change this and hardcode the PageLink (so editors cant change it). From various pages on the web I see this syntax :

    <EPiServer:SearchDataSource ID="SearchDataSource" runat="server" PageLink='<%# EPiServer.Core.PageReference.StartPage %>'>
        <SelectParameters>
            <asp:controlparameter name="SearchQuery" controlid="SearchText" propertyname="Text"/>
            <asp:controlparameter name="OnlyWholeWords" controlid="SearchOnlyWholeWords" propertyname="Checked"/>
        </SelectParameters>
    </EPiServer:SearchDataSource>

But when I use this syntax I always get no results. Please help! What am I doing wrong here?

#55817
Dec 19, 2011 16:41
Vote:
 

Ammendum:

Theres definatly something funky going on with:

PageLink='<%# EPiServer.Core.PageReference.StartPage %>'

As literally hardcoding the Page ID into this property works!

PageLink='1'

As literally hardcoding the Page ID into this property works!

This is all rather confusing, as <%# PageReference.StartPage.ID %> and <%# PageReference.StartPage.ToString() %>also don't work, but a hard coded ID is fine. 

If anyone can help bring clarity that would be great, Ideally I'd like to be able to use something like this:

PageLink="<%# new PageReference(3) %>"

This strikes me as the proper way to pass a pagereference to the control by way of an ID, however hard coded ID without any binding control is ok for now.

#55818
Dec 19, 2011 16:53
Vote:
 

You need to call DataBind() on your control from codebehind if you want to use databinding (<%#) syntax in the server attributes. 

#55828
Dec 19, 2011 18:17
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.