Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6922001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:20:59+00:00 2026-05-27T10:20:59+00:00

How can I add an item to a repeatable property programmatically in c#: let’s

  • 0

How can I add an item to a repeatable property programmatically in c#:

let’s say I have a node (node id 1234) and in it companies list property, where each item has comapny name and image (media picker).

how do I add an item programmtically ?

Here’s what I have so far:

        XPathNodeIterator xpathIterator = umbraco.library.GetXmlNodeById(NodeId.ToString());
        XElement node = XElement.Parse(xpathIterator.Current.OuterXml);

        var list = node.Descendants(propertyAlias).FirstOrDefault();

        // how do I add items here ? something like:
        list.Descendants().Add(...)

thanks.

The package I’m referring to is:
Repeatable Custom Content

update:
I think the solution is to update the xml in umbraco.config.
I have the following xml in umbraco.config:

<Companies id="1176" parentID="1447" ...>
    <umbracoNaviHide>0</umbracoNaviHide>
    <companyList>
        <item>
          <data alias="title">Company1</data>
          <data alias="image" />
          <data alias="text" />
          <data alias="date" />
        </item>
        <item>
          <data alias="title">Company2</data>
          <data alias="image">1943</data>
          <data alias="text" />
          <data alias="date" />
        </item>
      </items>
    </companyList>
  </Companies>

I am able to update umbraco.config programmatically, but the results are not updated in the backend, so that when I publish the companies node again, the changes are deleted. How can I update the umbraco.config and publish the node ?
Maybe I sh should update the database directly instead ?

My code:

Document companiesDoc = new Document(COMPANIESNODEID);

        XmlDocument document = content.Instance.XmlContent;

        XmlNode n = document.SelectSingleNode("//Companies[@id=" + COMPANIESNODEID.ToString() + "]").SelectSingleNode("//items");


        XmlNode newItem = document.CreateNode(XmlNodeType.Element, "item", null);


        XmlNode dName = document.CreateNode(XmlNodeType.Element, "data", null);
        XmlAttribute xn = document.CreateAttribute("alias");
        xn.Value = "title";
        dName.Attributes.Append(xn);
        dName.InnerText = companyName;

        XmlNode dImage = document.CreateNode(XmlNodeType.Element, "data", null);
        XmlAttribute xi = document.CreateAttribute("alias");
        xi.Value = "image";
        dImage.Attributes.Append(xi);
        dImage.InnerText = companyImage;

        XmlNode dText = document.CreateNode(XmlNodeType.Element, "data", null);
        XmlAttribute xt = document.CreateAttribute("alias");
        xt.Value = "text";
        dText.Attributes.Append(xt);

        XmlNode dDate = document.CreateNode(XmlNodeType.Element, "data", null);
        XmlAttribute xd = document.CreateAttribute("alias");
        xd.Value = "date";
        dDate.Attributes.Append(xd);

        newItem.AppendChild(dName);
        newItem.AppendChild(dImage);
        newItem.AppendChild(dText);
        newItem.AppendChild(dDate);

        n.AppendChild(newItem);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:20:59+00:00Added an answer on May 27, 2026 at 10:20 am

    I managed to solve the problem using this code:

    var doc = new Document(COMPANIESNODEID);
    
    
            XDocument xdoc = XDocument.Parse(doc.getProperty("companyList").Value.ToString());
    
            xdoc.Element("items").Add(new XElement("item",
                new XElement("data", new XAttribute("alias", "title"), companyName),
                new XElement("data", new XAttribute("alias", "image"), companyImage)));
    
            doc.getProperty("companyList").Value = xdoc.ToString();
    
    
            doc.Save();
    
            doc.Publish(new User(0));
            umbraco.library.UpdateDocumentCache(doc.Id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I add an item to a list if that item is essentially
I have the following HTML code: <ul id='item-list'></ul> <button id='add-item'>Add Item</button> <script type='text/template' id='item-template'>
I have a UITableView where I can add a new item with a touch
I've got a web page where the user can add a new item to
How can I add a start up item via command line on a mac?
Users on my site can add nodes of a custom type (let's call it
I have this code: foreach (var item in ListView1.Items) { ListView1.Items.Remove(item); ListView21.Items.Add(item); } the
How can i add an item to an existent window? I tried win.add() but
I am trying to dynamically add actionitems, I can add the item and it
On my website, people can add an item to their wishlist. When X number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.