的RenderingReference.RenderingItem
是指在/布局部分渲染项目.你能做的就是用RenderingReference.Settings.Datasource
.
所以你的代码看起来像:
foreach (var rendering in renderings) { if (rendering.Placeholder == "headerPlaceholder") headerRenderingDatasourceId = rendering.Settings.Datasource; else if (rendering.Placeholder == "/aboutSectionPlaceholder/textPlaceholder") aboutRenderingDatasourceId = rendering.Settings.Datasource; } Item headerRenderingDatasourceItem; if (!string.IsNullOrEmpty(headerRenderingDatasourceId) headerRenderingDatasourceItem = item.Database.GetItem(headerRenderingDatasourceId);