Read all items from a repeating table - InfoPath Dev
in

InfoPath Dev

Read all items from a repeating table

Last post 06-10-2009 03:44 PM by Hilary Stoupa. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-08-2009 12:28 AM

    • anpira
    • Not Ranked
      Female
    • Joined on 06-02-2009
    • Spain
    • Posts 4

    Read all items from a repeating table

    Hi everyone,

    First, I want to apologize if this topic already has gone out, but I have searched for the whole forum and do not find a good solution for my problem. I tell you:

    I have an InfoPath 2007 form and I have to read all the rows from a repeating table with VSTA (C#). I have a reapeating table with 2 columns and N rows and I must show all the field of my table, so I need to read each element from each row.

    I read the first row but the problem is that I don't know how to read the rest of rows, and the rest of fields of each row.

    Someone can help me?

     Thanks.

  • 06-10-2009 03:44 PM In reply to

    Re: Read all items from a repeating table

    Hi--

    You can use XPathNodeIterator for this. For example:

                XPathNodeIterator nodes = MainDataSource.CreateNavigator().Select("/my:myFields/my:group1/my:group2", this.NamespaceManager);
     
                string field1 = string.Empty;
                string field2 = string.Empty;
                string field3 = string.Empty;
     
                foreach (XPathNavigator node in nodes)
                {
                    field1 = node.SelectSingleNode("my:field1", this.NamespaceManager).Value;
                    field2 = node.SelectSingleNode("my:field2", this.NamespaceManager).Value;
                    field3 = node.SelectSingleNode("my:field3", this.NamespaceManager).Value;
                }

    This will get the value of each field and set a string variable to that value. If you wish to concatenate all the values, you'll need to modify this --  you can do something very simple like:

    field1 = node.SelectSingleNode("my:field1", this.NamespaceManager).Value + " " + field1;

    Hilary Stoupa

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