Microsoft Office Tutorials and References
In Depth Information
Adding or creating a new node in the main data source
Adding or creating a new node in the main
data source
An XML structure within an InfoPath form can include an internal recurring section
or a recurring table control. Suppose that you want to add a row to a recurring
section or a recurring table while some user action occurs or while a form is loading.
You can achieve this by applying the XPathNavigator object in conjunction with the
InsertAfter or AppendChildElement methods. In the following example, we create
a new node through the use of the button click event.
public void btn_addrow_Clicked(object sender, ClickedEventArgs e)
// Get a reference to the node the repeating table is bound to
XPathNavigator xNav = MainDataSource.CreateNavigator().
// Make a copy of the node by cloning it
XPathNavigator xRow = xNav.Clone();
// Set the new values of the row's fields
field1", this.NamespaceManager);
field2", this.NamespaceManager);
field3", this.NamespaceManager);
// Insert the new row after the last row in the table
Whenever we click on the AddRow button, a new row gets created as shown in the
following screenshot:
Search JabSto ::

Custom Search