November Happy Hour will be moved to Thursday December 5th.

Search page not working properly

Vote:
 

Hi,

i'm little bit confused over my search page. When doing a product search: My Search page lists up the products correctly and it works fine untill i click on "next page" or  whatever page number. When i do that, it brings  me back to the all product  page (the first page  --> list over all products). The funny part is when i click on search button again, it shows the content of the previous page i had clicked on ( let us say page 2).

 

Here is my files:

Search.ascx file:

<EPiServer:PageList id="epiPageList2" runat="server">
                <HeaderTemplate>
                <table>
                    <tr>
                        <th><asp:LinkButton ID="LinkButton1" runat="server" OnClick="Search_Click" Text="Product"></asp:LinkButton></th>
                        <th><asp:LinkButton ID="Produsent" runat="server" OnClick="Producer_Click" Text="Producer"></asp:LinkButton></th>
                        <th>MainSubstanse</th>            
                    </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td><EPiServer:Property ID="Property2" PropertyName="PageLink" runat="server" /></td>
                        <td><EPiServer:Property ID="Property1" PropertyName="Manufacturer" runat="server" /></td>
                        <td><%#MainSubstanse(Container.CurrentPage)%></td>
                    </tr>
                </ItemTemplate>    
                <FooterTemplate>
                </table>
                </FooterTemplate>
            </EPiServer:PageList>

Code behind:

 protected void Page_Load(object sender, EventArgs e)
        {
            PageData page = GetPage(PageReference.StartPage);
            FindPages(page, string.Empty, "PageName");
        }

        protected void Search_Click(object sender, EventArgs e)
        {
            PageData page = GetPage(PageReference.StartPage);
            FindPages(page, searchBox.Text, "PageName");
        }

 private void FindPages(PageData page, string searchText, string SortName)
        {
            PropertyCriteriaCollection searchCriteria = new PropertyCriteriaCollection();
            PageReference pageRef = page[PropertyContent] as PageReference;

            if (pageRef != null)
            {
                var criterias = new PropertyCriteriaCollection                   
                {                                        
                    new PropertyCriteria()                               
                    {                                       
                        Name = "PageTypeID",                                       
                        Condition = CompareCondition.Equal,                                       
                        Required = true,                                       
                        Type = PropertyDataType.PageType,                                       
                        Value = "20"                             
                    },                          
                    new PropertyCriteria()                                
                    {                                        
                        Name = "IsApproved",                                        
                        Condition = CompareCondition.NotEqual,                                        
                        Required = true,                                        
                        Type = PropertyDataType.Boolean,                                        
                        Value = "True"                              
                    }
                };


                if (searchText != string.Empty)
                {
                    PropertyCriteria criSearch = new PropertyCriteria()
                    {
                        Name = "PageName",
                        Condition = CompareCondition.Contained,
                        Required = true,
                        Type = PropertyDataType.String,
                        Value = searchText
                    };
                    criterias.Add(criSearch);
                }
           
                var pages = DataFactory.Instance.FindPagesWithCriteria(pageRef, criterias);

                string text = "{0} product found";
                if (pages.Count > 1)
                    text = "{0} products found";
                Total.Text = string.Format(text, pages.Count.ToString());

                epiPageList2.DataSource = pages;
                epiPageList2.Paging = true;
                epiPageList2.PagesPerPagingItem = 20;
                epiPageList2.SortBy = SortName;
                epiPageList2.SortDirection = EPiServer.Filters.FilterSortDirection.Ascending;
                epiPageList2.DataBind();
            }

        }

 I appreciate if someone can help me.

#73833
Aug 12, 2013 15:31
Vote:
 

Sounds like a databinding issue. Try setting epiPageList2.DataSource = pages and epiPageList2.Databind in the OnLoad method.

#73887
Aug 13, 2013 20:26
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.