Hi David,
Your code has been a great help. But I was wondering if you could be kind and help me understand some of the concepts so that I can tackle any variations instead of bugging you each time:
Here is the form structure that I'm working with:
Main Data Source: GetResult (I will use this data connection to populate the ListB, which will populate the form drop down list):
- myFields - input
- ParentSection - inputListA_ID
- MasterSection (repeating) - output (notes: these results are filtered based on what's selected in ListA)
- Goup1 - ID (this value will be assigned to listB_ID attribute in behind the form code)
- ListB (repeating) - Name (this value will be assigned to listB_Name attribute in behind the form code)
- listB_ID - listA_ID
- listB_Name
Based on your code, I've written the following and have few questions:
1. Do I need to get a selection of each element from the GetResult Data connection (as i've written one below)? Because I need "ID' and "Name" elements from this data connection.
string matchingSpotXPath = String.Format("/dfs:myFields/dfs:dataFields/tns:GetResult / tns:output / NewDataSet/output [listA_ID = '{0}']/Name", e.Site.Value);
2. How does the appending works here. I've a ListB node and then I've two attributes listB-ID and listB-Name. So, I'm stuck at trying to figure out on how to append the
ListB element and their corresponding attributes and assign their values. I've written the following but I need more guidance on getting access to attributes, appending attributes, and assiging values.
foreach (XPathNavigator spotNavigator in this.DataSources["GetResult"].CreateNavigator().Select(matchingSpotXPath, NamespaceManager))
{
using (XmlWriter writer = parent.AppendChild())
{
writer.WriteElementString("ListB",NamespaceManager.LookupNamespace("my"), spotNavigator.value);
}
}
Thanks.