Thursday, March 29, 2012

Programmatically add a blank row at the end of a InfoPath repeating table

Code snippet to add a blank row as last row in a InfoPath repeating table. 

//Get the repeating table node
XPathNavigator Group = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:AnalysisGroup/my:AnalysisTable", NamespaceManager);
//Get the Iterator object to iterate the node to last row
XPathNodeIterator rows = Group.Select("/my:myFields/my:AnalysisGroup/my:AnalysisTable", NamespaceManager);
//Loop to move the cursor to last row
for (int counter = 0; counter < rows.Count; counter++, rows.MoveNext()) ;
//clone the last row and insert it after that
//move the cursor to the last row
//Set all the fields in the row to blank
rows.Current.SelectSingleNode("my:ItemDesc", NamespaceManager).SetValue("");
rows.Current.SelectSingleNode("my:Tax", NamespaceManager).SetValue("");

No comments:

Post a Comment