I am doing project in Sitecore MVC. For every view rendering we are giving one data source for model reference but I need to get the field values from multiple items. So can we design the view renderings with multiple data sources?
You could create a new template to create datasource items that bundle your "multiple items" (in separate link type fields, or with a multi-select type field - as you want). This way you are able to set one item as datasource and find all your items on that single datasource.
The benefit of keeping the datasource approach is that datasources can be personalized, unlike rendering parameters. You could also use shared fields if you want, re-use the bundles, ...
You are able to use parameter templates and specify as much datasource as you need:
- Create a new template that uses “/System/Layout/Rendering Parameters/Standard Rendering Parameters” as a base template.
- Create the template fields (Datasource 2, Datasource 3, etc.) the same way you will do with any normal template. By using Standard Rendering Parameters as a base you wouldn't lose any of the Standard Template behavior your are used to.
- Attach your new template by using the “Parameters Template” field on your Sublayout.
- To add some data you just need to add the View rendering to the presentation details and edit its settings.
- Change your view code to handle multiple templates