I'm having problems trying to make this happen. I have a Client drop-down listbox and a Project drop-down listbox. I want to populate my Project drop-down listbox based on the clientName selected in the Client drop-down listbox. I have a web service (getProjectsForClient) that's sending back a DataSet.
Can I see more sample of the actual code you used, or can you help me?
Here is a sample of my code:
System.Xml.XmlDataDocument projectsXMLDataDoc = new
System.Xml.XmlDataDocument(this.RetDataset);
XmlNode projectListXMLNode = projectsXMLDataDoc.DocumentElement;
DataObject getProjectsForClientDataSource = thisXDocument.DataObjects[2];
IXMLDOMNode dtClientsDataSourceNode = getProjectsForClientDataSource.DOM.selectSingleNode(
"/*[local-name()='myFields']/*[local-name()='dataFields']/*[local-name()='getProjectsForClientResponse']/*[local-name()='getProjectsForClientResult']/*[local-name()='RetDataSet']/*[local-name()='NewDataSet']/*[local-name()='dtClients']");
IXMLDOMNode newRow;
foreach (XmlNode node in projectListXMLNode.ChildNodes)
{
newRow = dtClientsDataSourceNode.cloneNode(true);
newRow.selectSingleNode("Name").text =
node.FirstChild.InnerText;
getProjectsForClientDataSource.DOM.insertBefore(newRow,
dtClientsDataSourceNode);
}
I've put debug code, and the last statement in the foreach loop is not working. I don't get any errors, but my Project drop-down listbox isn't being filled with my list of values.
quote:
Originally posted by Alex Getman
I found the solution! :P
The point is that Infopath Document heavy relies at it's internal xml structure. In code that was provided above I am calling
documentRoot.appendChild(newRow);
That works fine if I got only one DataSource of type group inside main Infopath document datasource, but when another datasource was added an exception was trown because it's name was differ from first one.
So to fill more than one DataSources inside Infopath document, you should use something like:
documentRoot.insertBefore(newRow, jobRolesList);
where jobRolesList is the last added DataSource.
Also you should always keep in mind that all C# code manipulations with Infopath DataSources will hardly depends on it's internal xml structure (xsd schema actually)