Filling dropdownlist from two sources - XML & webservice

D

Dotnetdev

Hi Friends,

Please need your help in solving this issue.

I have a dropdown list which is connected to an XML file and it has another
connection(secondary datasource) which actually have the data is a web
service.

My connection names are "MainDS" - connection to xml file & secDS -
connection to web service.

I need to fill the drop down list. I tried this code. I get Null reference
error.

XPathNavigator mainnav = MainDataSource.CreateNavigator();
XPathNavigator myname1 =

mainnav.SelectSingleNode(""dfs:myFields/dfs:dataFields/s0:GetUserCollectionFromSiteREsponse/s0:GEtUserCollectionFromSiteResult/s0:GetUserCollectionFromSite/s0:Users/s0:User", NamspaceManager);
//XPathNavigator myname1 =
mainnav.SelectSingleNode("/my:myfields/my:myField1", NamspaceManager);

XPathNavigator secds = this.DataSources["Users"].CreateNavigator();
XPathnavigator myname2 =

secds.SelectSingleNode("dfs:myFields/dfs:dataFields/s0:GetUserCollectionFromSiteREsponse/s0:GEtUserCollectionFromSiteResult/s0:GetUserCollectionFromSite);

myname1.InnerXML = myname2.InnerXML();

where dfs:...... is XPath of the corresponding datasources.

I got a NullReference error. Please help me. I'm in urgent need of it.
Note: Even tried the commented code instead of the code above that. Even
that returned null reference.

Please help
Thanks in advance
 
S

Shiva (GGK Tech)

Hi

In the InfoPath 2007 managed object model, you can reference the XML for a
secondary data source from the form code-behind using the syntax:

XPathNavigator node = this.DataSources["MainDS"].CreateNavigator();

For the main data source, use:

XPathNavigator node = this.MainDataSource.CreateNavigator();

The XPathNavigator instance is initially positioned to the document-level
node in the data source XML.

And ‘dfs’ is namespace prefix.
 
D

Dotnetdev

Hi,

i tried the following code: I'm i right. I got the same error.

XPathNavigator mainnav = this.MainDataSource.CreateNavigator();
XPathNavigator myname1 =
mainnav.SelectSingleNode(""dfs:myFields/dfs:dataFields/s0:GetUserCollectionFromSiteREsponse/s0:GEtUserCollectionFromSiteResult/s0:GetUserCollectionFromSite/s0:Users/s0:User", NamspaceManager);
XPathNavigator secds = this.DataSources["Users"].CreateNavigator();
XPathnavigator myname2 =
secds.SelectSingleNode("dfs:myFields/dfs:dataFields/s0:GetUserCollectionFromSiteREsponse/s0:GEtUserCollectionFromSiteResult/s0:GetUserCollectionFromSite);
myname1.InnerXML = myname2.InnerXML();

Still I'm getting the null reference error. It says in the last line of
code(myname1.InnerXML = myname2.InnerXML();) - object reference not set to an
instance of an object.

Please help
Thanks



Shiva (GGK Tech) said:
Hi

In the InfoPath 2007 managed object model, you can reference the XML for a
secondary data source from the form code-behind using the syntax:

XPathNavigator node = this.DataSources["MainDS"].CreateNavigator();

For the main data source, use:

XPathNavigator node = this.MainDataSource.CreateNavigator();

The XPathNavigator instance is initially positioned to the document-level
node in the data source XML.

And ‘dfs’ is namespace prefix.
--
Shiva
http://www.ggktech.com


Dotnetdev said:
Hi Friends,

Please need your help in solving this issue.

I have a dropdown list which is connected to an XML file and it has another
connection(secondary datasource) which actually have the data is a web
service.

My connection names are "MainDS" - connection to xml file & secDS -
connection to web service.

I need to fill the drop down list. I tried this code. I get Null reference
error.

XPathNavigator mainnav = MainDataSource.CreateNavigator();
XPathNavigator myname1 =

mainnav.SelectSingleNode(""dfs:myFields/dfs:dataFields/s0:GetUserCollectionFromSiteREsponse/s0:GEtUserCollectionFromSiteResult/s0:GetUserCollectionFromSite/s0:Users/s0:User", NamspaceManager);
//XPathNavigator myname1 =
mainnav.SelectSingleNode("/my:myfields/my:myField1", NamspaceManager);

XPathNavigator secds = this.DataSources["Users"].CreateNavigator();
XPathnavigator myname2 =

secds.SelectSingleNode("dfs:myFields/dfs:dataFields/s0:GetUserCollectionFromSiteREsponse/s0:GEtUserCollectionFromSiteResult/s0:GetUserCollectionFromSite);

myname1.InnerXML = myname2.InnerXML();

where dfs:...... is XPath of the corresponding datasources.

I got a NullReference error. Please help me. I'm in urgent need of it.
Note: Even tried the commented code instead of the code above that. Even
that returned null reference.

Please help
Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top