Sitecore Static binding With Placeholder

65 Views Asked by At

I have a requirement where I am rendering placeholder dynamically in a view and I wanted to add some of the existing components in that placeholder. So the code goes something like below.

for (int i = 1; i <= Columns; i++)
{
      @Html.Sitecore().DynamicPlaceholder("ec-" + i)
}

Then in another loop I am adding the component

@Html.Sitecore().Rendering(ComponentItemId, new { DataSource = ds.Id })    

There is no option to pass placeholder name here as it's static binding.

But what if I wanted pass the placeholder name and wanted to render the component in that placeholder and I want to do it from code not from experience editor like manually adding components to page.

I have the dynamic placeholder id generated at runtime. Please suggest me if this is something possible through some customization

So like in runtime how can we add a component to a page in to a specific placeholder if we know the placeholder along with data source

0

There are 0 best solutions below