InfoPath 2007 / C#
I'm trying to copy data from a sharepoint list to a repeating table in
an infopath form so that it can be viewed when not connected to the
sharepoint list. I am trying to copy the data by the click of a button. I've never really done much
with infopath before (none with 2007) so any pointers would be
appreciated. The following is what I've tried so far. I'm having
problems with the current view part. I get an error that says:
"Either the combination of values for the View.SelectNodes call is
an invalid selection, or the values are not defined for this view,
defined for this view more than once, or not selectable in the view."
Any idea how to fix or get around this?
public void CTRL20_5_Clicked(object sender, ClickedEventArgs e)
{
// Write your code here.
XPathNavigator rootMain = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group5", NamespaceManager);
XPathNavigator rootSecondary = this.DataSources["Universities"].CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Universities", NamespaceManager);
// Select nodes in specified XPathNavigator.
CurrentView.SelectNodes(rootSecondary);
XPathNodeIterator selectedNodes = CurrentView.GetSelectedNodes();
XmlWriter writer = rootMain.SelectSingleNode("/my:myFields", NamespaceManager).AppendChild();
string myNamespace = NamespaceManager.LookupNamespace("my");
foreach (XPathNavigator selectedNode in selectedNodes)
{
writer.WriteStartElement("group6", myNamespace);
writer.WriteElementString("field3", myNamespace, selectedNode.ToString());
writer.WriteEndElement();
}