简体   繁体   中英

How to fetch the Item Property/Fields in Sitecore?

I am trying to fetch a field called footer from the Item FooterComponent and want to display.This is the code I have tried but cannot fetch and display.

cs code:

Item footerText=Sitecore.content.Database.GetItem(GUID);
string MyFooter=FooterText["Footer"];
txtFooter.Item = MyFooter;

ascx code:

<sc:fieldrenderer runat="server" id="txtFooter" fieldname="Footer"/>

You should not set a string value of the field to the field renderer. Just set correct item and field name:

Item footerTextItem = Sitecore.content.Database.GetItem(GUID);
txtFooter.Item = footerTextItem;
<sc:fieldrenderer runat="server" id="txtFooter" fieldname="Footer"/>

See more information here: https://sitecoresandbox.com/tag/fieldrenderer/

Also read What's a good way to set the Item or DataSource attribute of a FieldRenderer?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM