InfoPath Basics: Repeating control basics in InfoPath
This article explains the basics of repeating tables and repeating sections in InfoPath.
Introduction to repeating controls
A repeating control in InfoPath is a control to which you can dynamically (via the InfoPath user interface or through code) add rows or sections, or from which you can dynamically remove rows or sections. A section is a control that can contain other controls.
There are 3 types of repeating controls in InfoPath:
- Repeating table controls
- Repeating section controls
- Horizontal repeating table controls (only available in non-browser-compatible InfoPath form templates)
The name Repeating Table is a little bit misleading. Repeating Rows would have been a better name for a Repeating Table, because the rows in the table are repeated, not the table itself.
How to add a repeating table to an InfoPath form template
To add a repeating table to an InfoPath form template:
- In InfoPath on the InfoPath form template, place the cursor where you want to add a repeating table.
- On the Insert menu, click Repeating Table.
- On the Insert Repeating Table dialog box, enter a number for the Number of columns you want, and click OK.
How to add a repeating section to an InfoPath form template
To add a repeating section to an InfoPath form template:
- In InfoPath on the InfoPath form template, place the cursor where you want to add a repeating table.
- On the Insert menu, click More Controls.
On the Controls task pane, click Repeating Section.
Figure 1. Repeating Section control on the Controls task pane in InfoPath.Click inside the repeating section you just added to the InfoPath form template (a hatched border appears around the repeating section), and then click and add controls from the Controls task pane to the repeating section.
Figure 2. Adding controls to a repeating section in InfoPath.
Data structure of a repeating node
Structurally, there is no difference between a repeating table and a repeating section.
While the 3 types of repeating controls may look different on an InfoPath form, their data source structure is the same. This is important to remember especially when you are writing code to for example programmatically add a row to a repeating table.
The data structure of a repeating node consists of:
- A non-repeating group node
- A repeating group node
- One or more fields
Figure 3. Basic data structure for a repeating node (table or section) in InfoPath.
If you create a repeating table with the data structure displayed in Figure 3 and then preview the InfoPath form and add 3 rows to the repeating table, the structure of the repeating table would be as displayed in Figure 4, where repeating-group-node1, repeating-group-node2, and repeating-group-node3 represent the rows of the repeating table with each repeating group node having its own field1, field2, and field3 fields. The non-repeating group node would be the table itself, which functions as a container for the rows.
Figure 4. The structure of a repeating table's rows in InfoPath.
The output of an InfoPath form is XML, so the XML for the repeating table shown in Figure 4, would look something like:
<non-repeating-group-node>
<repeating-group-node>
<field1 />
<field2 />
<field3 />
</repeating-group-node>
<repeating-group-node>
<field1 />
<field2 />
<field3 />
</repeating-group-node>
<repeating-group-node>
<field1 />
<field2 />
<field3 />
</repeating-group-node>
</non-repeating-group-node>
Note: XML namespaces have been omitted for clarity.
The XML for a repeating section with 3 fields in each section would look similar to the XML displayed in Figure 4.
Related InfoPath Articles:
- 4 Ways to programmatically add a row to a repeating table in InfoPath
- Auto-fill a repeating table with data from a SharePoint list when a row is inserted
- Programmatically delete the first row of a repeating table in InfoPath
- Programmatically delete all of the rows of a repeating table in InfoPath
- Programmatically retrieve the value of another field in the same row of a repeating table in InfoPath 2007
