Ends an edit operation.
To change the field values or name of an item, the item must be in editing mode. An item can enter editing mode by calling BeginEdit and leave using EndEdit. If the item is being edited without being in editing mode, an exception is raised. Changes to the items, is committed to the database when the editing mode is left.
The following examples updates news items in a news section with an old or yesterday marking. The two methods shows two different way of entering edit mode. public void UpdateNewsToOld(Item newsSection) { foreach(Item news in newsSection.Children) { if (news.TemplateName == "News") { news.BeginEdit(); try { news["Is Old"] = "1"; } finally { news.EndEdit(); } } } }
public void UpdateNewsToYesterday(Item newsSection) { foreach(Item news in newsSection.Children) { if (news.TemplateName == "News") { using(new EditContext(news)) { news["Yesterday"] = "1"; } } } }
Item Class | Sitecore.Data.Items Namespace | Item.EndEdit Overload List