The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
Each IDocument carries the information for the item's ContentType in the contain the "ContentType" field where you can obtain the correct information what kind of item you're dealing with.
Once you've resolved the type, you can then operate with this type's specific properties, however you first need to get the actual item (remember what you've been working with so far is the Lucene document, not the Sitefinity item).
This is done by obtaining the item's ID. By default the field name where the original Sitefinity content ID is stored inside each Lucene document varies depending on how the particular module has configured its inbound pipe. The unified concept that we have adopted is that all Content types will use the "OriginalItemId" field.
Once we have information about the ContentType and the OriginalItemId this allows us to determine which content manager we need to call, and which Id to pass, in order to retrieve the actual item. Form then on operating with the item is just as with any item of that type - you can get its properties and use them depending on your specific use case scenario.
So for the SearchResults widget we can easily create an external template based on the default one, that will allow us to use code-behind, subscribe to the ResultsListItemDataBound event in the template code-behind and do something like:
DotNetImageControl = System.Web.UI.WebControls.Image;
SearchResultsProducts : System.Web.UI.UserControl
sender, EventArgs e)
.resultsList.ItemDataBound += ResultsListItemDataBound;
.catalogManager = CatalogManager.GetManager();
.libMan = LibrariesManager.GetManager();
.pageMan = PageManager.GetManager();
sender, RepeaterItemEventArgs e)
var myitem = e.Item.DataItem
//You need to check for the type of the item you have gotten in your search results
var type = myitem.GetValue(
//Documents enter the index with an Id field
var docItem = libMan.GetDocument(
var path = docItem.FilePath;
//Pages get in the index with OriginalItemId field
//Here's how you can display a page property in your search results
var ID =
//you can now get the item with its manager and access its properties,
//since you'll be working with an object of the correct type
var page = pageMan.GetPageNode(ID);
//check if the PageNode has PageData
//now you can simply get a control from your template and set the value to it,
//so it can be displayed
var literalControl = e.Item.FindControl(
literalControl.Text = page.Page.Description;
//Products, and Content items also enter the index with OriginalItemId field
//get the control that will display our data on the template
var image = e.Item.FindControl(
//get the actual Product item
var product = CatalogManager.GetManager().GetProduct(ID);
//ste the property value to the control so it will be displayed on the frontend
image.ImageUrl = product.PrimaryImageUrl;
For your convenience I'm attaching an archive of the control template above to this post.
In conclusion, you've probably realized that this post just scratches the surface on the amount of modifications that can be done when customizing your search results, hope it helps you achieve your desired functionality.
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Subscribe to get all the news, info and tutorials you need to build better business apps and sites
Copyright © 2019 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.