Hello All,
I currently have a situation in which I need to dynamically populate a new row in a repeating table on an InfoPath form. I currently have three fields in a repeating table (field1, field2, field3). I also have a button that says Add Row. The code behind the button dynamically creates/appends a new field onto each previous field when the button is clicked and populates the text (Cell 1, Cell2, Cell3) respectfully. I also have a fourth text field on the form, outside of the repeating table called field4. Instead of populating standard text into fields 1,2,3, I wish to be able to copy the text/value entered in field4 into the field(s) inside the repeating table. It sounds easy but I have found it extremely difficult to understand each class and its methods for the XML object model. Could someone please take a look at the code below and perhaps show me the code to do just that. The code below is placed on the Add Row button clicked event. Any help would be wonderful. Thanks
XmlDocument doc = new XmlDocument();
XmlNode group = doc.CreateElement("group2", NamespaceManager.LookupNamespace("my"));
XmlNode field = doc.CreateElement("field1", NamespaceManager.LookupNamespace("my"));
XmlNode node = group.AppendChild(field);
node.InnerText ="Cell 1"; //<--------Instead of text here I would like the value from field4. This would require creating an instance of field4 and I am unsure of the syntax----------->
field = doc.CreateElement("field2", NamespaceManager.LookupNamespace("my"));
node = group.AppendChild(field);
node.InnerText ="Cell 2";
field = doc.CreateElement("field3", NamespaceManager.LookupNamespace("my"));
node = group.AppendChild(field);
node.InnerText ="Cell 3";
doc.AppendChild(group);
MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1", NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());