Can any one tell me if I can use a ASP Control instead of Field Renderer to display the field.Please see below illustration.
Note:I need to do it in the Item Databound Event of Repeater.
I have a template with Field as External Link .Eg :Contact US .One way to display that link in the page is using field renderer as below.
ContactUS.aspx:
<asp:Repeater ID="rptContactUS" runat="server" OnItemDataBound="Menu_OnItemDataBound">
<ItemTemplate>
<item><sc:FieldRenderer ID="frContactUS" runat="server"/></item>
</ItemTemplate>
</asp:Repeater>
ContactUS.aspx.cs:
protected void Menu_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
Field item = (Field)e.Item.DataItem;
if (item != null)
{
FieldRenderer frContactUS= (FieldRenderer)e.Item.FindControl("frContactUS");
if (frContactUS!= null)
{
frContactUS.FieldName = item.Name;
}
}
}
The above code works fine.My Question is Whether I can use a Asp control instead of FieldRenderer and assign the link value from the Field Item to asp href property of the link in item databound event of repeater.If yes,Please tell me how?
Thanks,
Suhas
Yes you can. From what I see in your example you are binding Field to the Menu.
You could also bind a List of Items to your menu. You can then retrieve the item’s fields in the repeater like this:
}
From here you will have the url field (obviously you should give the correct field name instead of url.
The LinkField has several properties as described in the general Sitecore documentation that can be found @ http://sdn.sitecore.net.