Hi,
Add an on after change event for the field. And get the repeating node from the sample and add it to the parent group node. The following code will be useful to fulfill your requirement.
[InfoPathEventHandler(MatchPath = "/my:myFields/my:group6/my:group7/my:field22", EventType = InfoPathEventType.OnAfterChange)]
public void field22_OnAfterChange(DataDOMEvent e)
{
if (e.IsUndoRedo || e.Operation != "Insert" || e.Parent.nodeName != "my:field22")
{
return;
}
if (e.Site.text.Length != 0)
{
IXMLDOMDocument2 sampleDataDom = (IXMLDOMDocument2)thisXDocument.CreateDOM();
sampleDataDom.setProperty("SelectionNamespaces", "your form name space");
sampleDataDom.load("sampledata.xml");
IXMLDOMNode sampleGroupNode = sampleDataDom.selectSingleNode("/my:myFields/my:group6/my:group7");
IXMLDOMNode parentNode = thisXDocument.DOM.selectSingleNode("/my:myFields/my:group6");
parentNode.appendChild(sampleGroupNode);
}
}
Here "/my:myFields/my:group6/my:group7 -> is the repeating section xpath
/my:myFields/my:group6/my:group7/my:field22 -> repeating section field xpath