I tried a few solutions here but none worked for me. Trying to bind link items to a repeater. I don't see any output in the rendered page. Not even the text.
Mark Up:
<asp:Repeater ID="rbBrandNav" runat="server" ItemType="Sitecore.Data.Items.Item">
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<sc:FieldRenderer FieldName="Destination URL" runat="server" />
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
C#:
Sitecore.Data.Database context = Sitecore.Context.Database;
Sitecore.Data.Items.Item brandNavMenu = context.GetItem("{some-guid}");
if (brandNavMenu != null)
{
rbBrandNav.DataSource = brandNavMenu.GetChildren();
rbBrandNav.DataBind();
}
Data Template:
Nav Item
Nav Item Name - Single-Line Text
Destination URL - General Link
An example Item created
About Us
Nav Item Name - About Us
Destination URL
Link Type - External Link
Title - About Us Title
Description - About Us Des
Url - www.example.com
Target - _blank
When I bind the Item.Name to the repeater, I see the items. But when binding the links, no output. In viewsource, I see the 4 <li>
generated.
Try to add Item attribute to the FieldRenderer like that:
<sc:FieldRenderer FieldName="Destination URL" runat="server" Item="<%# Container.DataItem %>">