Create an item

You can use the Sitecore.Data.Items.Item.Add() method to create an item. The parent item and the data template for the new item must exist before you create the item. For example, to create the /Sitecore/Content/Home/MyItem item using the Sample/Sample Item data template item in the Master database:

RequestResponse
Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master");

Sitecore.Data.Items.Item home = master.GetItem("/sitecore/content/home");

Sitecore.Data.Items.TemplateItem sample = master.Templates["sample/sample item"];

Sitecore.Data.Items.Item myItem = home.Add("MyItem", sample);

It is recommended that you do not perform this task in a production environment (on the website); there is no access to the Master database.

Do you have some feedback for us?

If you have suggestions for improving this article,