IT tutorials
 
Technology
 

InfoPath with SharePoint 2010 : Dynamically Populate a Repeating Table - Loop Through the Secondary Data Source , Populate the Repeating Table

1/26/2014 8:14:17 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

1. Loop Through the Secondary Data Source

Scenario/Problem:You need to loop through the secondary data source.

Solution:Create a while loop to loop through the rows.

The loop is the main component of populating the repeating table. You loop through the secondary data source through the XPathNodeIterator collection (rows) that you defined in the previous section, retrieving the values from each row. The code to perform this is shown in Listing 1. Place this after the secondary data source setup. You will add more code to the loop in the next section.

Tip

Check the XPath of the secondary data source fields to determine how to call reference their nodes.


Listing 1. Loop Through the Secondary Data Source
//Loop through the secondary data source
while (rows.MoveNext())
{
string office = rows.Current.SelectSingleNode("D:TITLE",
NamespaceManager).Value.ToString();
string region = rows.Current.SelectSingleNode("D:REGION",
NamespaceManager).Value.ToString();
string id = rows.Current.SelectSingleNode("D:ID",
NamespaceManager).Value.ToString();
}

Note

The variables defined in the loop should correspond to the fields that are returned from the secondary data source.

2. Populate the Repeating Table

Scenario/Problem:You need to populate the repeating table.

Solution:Use the XMLWriter to write the values from the secondary data source to the repeating group in the form.

The repeating table is actually part of the main data source, so you can access that and use the XMLWriter to write the field values from the secondary data source to the table.

You will need the names of the groups and the fields that are bound to the repeating table in the form. In this example, the groups are group1 and groupRepeat, and the fields are field1, field2, and field3.

Place the code in Listing 2 within the while loop from the preceding section.

Tip

Copy the XPath from the repeating group to ensure the correct path is entered.


Listing 2. Populate the Repeating Table
//Populate the repeating table
using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingle-
Node("/my:myFields/my:group1", NamespaceManager).AppendChild())
{
writer.WriteStartElement("groupRepeat", myNamespace);
writer.WriteElementString("field1",myNamespace,office);
writer.WriteElementString("field2", myNamespace,region);
writer.WriteElementString("field3", myNamespace,id);
writer.WriteEndElement();
writer.Close();
}

Note

The order in which you write the values to the table should be the order that they appear in the main data source. Otherwise, you will receive a non-datatype schema validation error.

 
Others
 
- InfoPath with SharePoint 2010 : Dynamically Populate a Repeating Table - Create a Namespace Variable, Access the Secondary Data Source
- InfoPath with SharePoint 2010 : Dynamically Populate a Repeating Table - Create a Changed Event Method
- InfoPath with SharePoint 2010 : Dynamically Populate a Repeating Table - Set Up the Initial Form
- Windows 7 : Managing Application Compatibility (part 6) - Installing and Configuring the Application Compatibility Toolkit
- Windows 7 : Managing Application Compatibility (part 5) - Using the Application Compatibility Toolkit - Compatibility Administrator , Internet Explorer Compatibility Test Tool
- Windows 7 : Managing Application Compatibility (part 4) - Using the Application Compatibility Toolkit - Application Compatibility Manager
- Windows 7 : Managing Application Compatibility (part 3) - Using the Program Compatibility Troubleshooter , Suppressing Compatibility Controls Using Group Policy
- Windows 7 : Managing Application Compatibility (part 2) - Evaluating Application Incompatibility Solutions - Using Compatibility Modes
- Windows 7 : Managing Application Compatibility (part 1) - Creating an Application Inventory
- Windows 7 : Designing an Application Deployment Strategy (part 3) - Deploying Applications - Selecting an Application Deployment Method
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us