More in this section
Forums / Developing with Sitefinity / Customising search results

Customising search results

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 1 answered
  1. sathiyaseelan
    sathiyaseelan avatar
    82 posts
    Registered:
    26 Aug 2008
    28 May 2010
    Link to this post
    Hi sir,

    I have a site search in my site that searches all sitefinity and news pages. I need a row index to be added in each search item. for ex

    1. search item 1
    2. search item 2
    ......

    on clicking next page it sh'd be

    3. search item 3
    4. search item 4

    I used item index in the repeater but the same no is showing in every pages if i go on. It should be incrementing on every page till the last.

    can it be done?

    Thanks,
    sathiya
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    28 May 2010
    Link to this post
    Hello sathiyaseelan,

    You can calculate the number of the item by using something like the bellow:
    <script type="text/C#" runat="server">
        protected void Page_Load()
        {
            rptResults.ItemDataBound += new RepeaterItemEventHandler(rptResults_ItemDataBound);
        }
     
        void rptResults_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Literal count = (Literal)e.Item.FindControl("Count");
                //the default number of items per page is 10
                count.Text = (e.Item.ItemIndex + 1 + (this.pager1.SelectedPage-1)*ItemsPerPage).ToString();
            }
             
        }
    </script>
    <asp:Repeater ID="rptResults" runat="server">
        <HeaderTemplate>
            <dl class="searchResults">
        </HeaderTemplate>
        
        <ItemTemplate>
            <asp:Literal ID="Count" runat="server"></asp:Literal>
            <dt><strong><a href='<%#DataBinder.Eval(Container.DataItem, "Url")%>'><%#DataBinder.Eval(Container.DataItem, "Title")%></a></strong></dt
            <dd><%#DataBinder.Eval(Container.DataItem, "Snippet")%></dd>
            <dd><em><a href='<%#DataBinder.Eval(Container.DataItem, "Url")%>'><%#DataBinder.Eval(Container.DataItem, "Url")%></a>
                        </em></dd>
        </ItemTemplate>
        <FooterTemplate>
            </dl>
        </FooterTemplate>
    </asp:Repeater>

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
  3. sathiyaseelan
    sathiyaseelan avatar
    82 posts
    Registered:
    26 Aug 2008
    28 May 2010
    Link to this post
    o great. Thank you very much.
Register for webinar
3 posts, 1 answered