I have the code on a clicked event to reset a repeating node (deleting all existing rows - see code)... I am looking for the best way to add back a default row. I tried using xmlwriter, but this requires listing all columns of the repeating node, in this case more than 40 columns - just not efficient! The default row is the basis for creating many rows programmatically. The property 'Allow users to insert and delete' is not an option because of how the form functions.

public void NewResetHiddenUntilSubmitted_Clicked(object sender, ClickedEventArgs e)
        XPathNavigator root = MainDataSource.CreateNavigator();

        // Count the amount of Rents nodes
        XPathNodeIterator iter = root.Select(
        int rentsNodesCount = iter.Count;

        // Retrieve the first Rents node Starting at the first row
       XPathNavigator firstRentsNodeNav =

        // Retrieve the last Rents node
        XPathNavigator lastRentsNodeNav =
       root.SelectSingleNode("/my:RepeatingTable[" +
       rentsNodesCount.ToString() + "]",

        // Delete the range of nodes from the first to the last nodes

        //This is where I need to add back one default row

1 Answer 1


Thanks so much for your codes. What I did to get the row is I delete only starting from the second row and I set the first row's value to be empty. So it's like this for my codes. Sorry it is in VB but it's similar.

              Dim iter As XPathNodeIterator = root.Select("/my:myFields/my:NewResourceType/my:NewResourceTypeRow", NamespaceManager)
              Dim rowsCount As Integer = iter.Count
              root.SelectSingleNode("/my:myFields/my:NewResourceType/my:NewResourceTypeRow[1]/my:title", NamespaceManager).SetValue("")

              firstMethodNav = _
              root.SelectSingleNode("/my:myFields/my:NewResourceType/my:NewResourceTypeRow[1+1]", _
            lastMethodNav = _
              root.SelectSingleNode("/my:myFields/my:NewResourceType/my:NewResourceTypeRow[" & _
              rowsCount.ToString() & "]", _

  • Thanks for your thoughts! I ended up creating a default row with an xml document and applied it as follows: 'XmlDocument doc = new XmlDocument(); XmlNode group1 = doc.CreateElement("RentsRepeatingGroup", NamespaceManager.LookupNamespace("my")); XmlNode newRow = CreateOrResetRentData(true, doc, null, string.Empty, string.Empty, 0, 0, 0, false); group1.AppendChild(newRow); root.SelectSingleNode("/my:myFields/my:FinancialData/my:RentGroup/my:RentsRepeatingGroup", NamespaceManager).ReplaceSelf(group1.CreateNavigator());'
    – Greg
    Oct 30, 2013 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.