Sitefinity CMS allows you to query for a specific list item by its ID. To search for specific list items based on any other property or criteria, see For developers: Find list items.
NOTE: The code examples below work with the ID of the master version of the item and return the live version of the item. For more information about other scenarios, see For developers: Query master and live versions.
When querying the live version of a specific list item by the ID of its master version, you must perform the following:
NOTE: The live version is used only when displaying the list item in a front-end scenario. To modify the list item, consider using the master version. To transfer the changes to the live version, publish the master version.
The following examples query the live version of a list item by the ID of its master version.
Native API
First, you get an instance of the ListsManager class. You get the specified list item by querying all items and filtering the collection by the ID of the list item. If the item exists, you get its live version. If no live version exists (i.e. the list item has not been published), null is returned. Finally, you return the list item.
ListsManager
null
To find the list item, you can also use the GetListItem method passing masterListItemId:
GetListItem
masterListItemId
NOTE: Calling GetListItem(masterListItemId) throws an exception of type ItemNotFoundException, if there is no list item with the specified Id.
GetListItem(masterListItemId)
ItemNotFoundException
Id
Fluent API
First, you use the plural facade of the list item to assure that the item with the specified Id exists. Then, you use the GetLive method of the singular facade to get the instance of the live version. Finally, you return the list item.
GetLive
To query all list items, use the following code sample::
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important