Inserting a repeating section that contains repeating table. - InfoPath Dev
in

InfoPath Dev

Inserting a repeating section that contains repeating table.

Last post 08-10-2011 01:48 AM by Stuat. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 08-09-2011 08:12 AM

    • Stuat
    • Not Ranked
    • Joined on 07-04-2011
    • Posts 4

    Inserting a repeating section that contains repeating table.

    Dear all,

    I have a browser enabled infopath 2007 form, and I am using code behind it to insert new rows into the repeating table.

    I have attached the schema and how I designed the form.

    In the code for the Add subgroup 1,

    I have:

    Dim myNamespace As String = NamespaceManager.LookupNamespace("my")

    Using writer As XmlWriter = MainDataSource.CreateNavigator().SelectSingleNode( _

    "/my:myField/my:Group1/Sub Sub group 1", NamespaceManager).AppendChild()

    writer.WriteStartElement("Sub group 1", myNamespace)

    writer.WriteElementString("field 6", myNamespace, 0)

    writer.WriteElementString("field 7", myNamespace, 0)

    writer.WriteEndElement()

    writer.Close()

    End Using

     This code works find and inserts the field as I expect.

    For inserting the section group 1, I have:

    Dim myNamespace As String = NamespaceManager.LookupNamespace("my")

    Using writer As XmlWriter = MainDataSource.CreateNavigator().SelectSingleNode( _

    "/my:myField/my:Group Group 1/", NamespaceManager).AppendChild()

    writer.WriteStartElement("Group 1", myNamespace)

    writer.WriteElementString("field 4", myNamespace, 0)

    writer.WriteElementString("field 5", myNamespace, 0)

    writer.WriteElementString("Sub Sub group 1", myNamespace, "") 'I know this bit might not be correct

    writer.WriteEndElement()

    writer.Close()

    End Using

     This one however, inserts only the header based on the poor code i think i wrote for it, but then , if i click the Add sub group 1 button to add the repeating table in this particular section, it only ends up adding it only to the very first one.

    Please can anybody help in fining out what the problem is?

    Many thanks in advance.


  • 08-10-2011 01:48 AM In reply to

    • Stuat
    • Not Ranked
    • Joined on 07-04-2011
    • Posts 4

    Re: Inserting a repeating section that contains repeating table.

    Incase anybody is struggling with this, I have found the solution.

    I found the current group 1 this way:

    Dim section As XPathNavigator = MainDataSource.CreateNavigator()

    Dim CurrentSection As XPathNodeIterator = section.Select("/my:myFields/my:GroupGroup1/my:Group1", NamespaceManager)

    Dim SectionCounter As Integer = CurrentSection.Count

    And I referenced the current Group when adding subgroup 1 this way:

    "/my:myField/my:Group1[" & SectionCounter & " /Sub Sub group 1", NamespaceManager).AppendChild()

    This ensured that adding sub group 1 adds it to the most current group 1.

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.