Multiple items in a data source
Version:
Note
This topic is valid for Sitecore 9, Update 2, and later.
You can specify a query in data source field of an MVC control, and this query can return multiple items. You access these items either in the controller code or in the view code.
For example, if you have a number of items named Sample Item 1, Sample Item 2, and so on, you specify the value of the Data Source property of a control as query: text: Sample Item* to retrieve all of these items.
The following example describes accessing the retrieved items:
Accessing items in the controller code
Accessing items in the controller code
You use the RenderingContext.Current.Rendering.Items property to obtain a list of items:
Accessing items in the view code
Accessing items in the view code
You access the items in the view code in the following way: