Loop though repeating group in InfoPath 2007

D

digitor

I have a repeating group which I wish to loop through to check against.
How can I (Programmatically) loop through all the nodes in a repeating
group and get access to the collection it holds?
Be good if you could post a code example on how to do this. (using
InfoPath 2007 with the new object model)

Greg
 
A

Alexander Ekzarov

Did you try XPath ??
For example, if you have some group1 wich have repeating field CustomerName,
and you want to choose CustomerName wich equals "Mark Jhon" you whould write
something like this in:
/group1[@CustomerName='Mark Jhon']/CustomerName

in formula of some field or in C# code...

I hope it will help...
 
D

digitor

Thanks heaps people for your replys!!

Hello digitor,

You must combine the new XPathNodeIterator and the XPathNavigator classes in
the new Object Model to loop through repeating nodes.

I created a form with a bullet list on it. The group is called "group1" and
the repeating field within the group called "field1"

string xpathValue1 = "/my:myFields/my:group1/my:field1";
XPathNavigator navigator = MainDataSource.CreateNavigator();
XPathNodeIterator nodeIterator = navigator.Select(xpathValue1,
NamespaceManager);

while (nodeIterator.MoveNext())
{
XPathNavigator node = nodeIterator.Current;
string value = node.Value; // you can check the value
}

Success!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top