Quantcast
Channel: SharePoint 2013 - Development and Programming Forum
Viewing all articles
Browse latest Browse all 1404

infopath2010 code get data from sharepoint list

$
0
0

hello

when i write code in infopath 2010 to get list data 

this is code

  SPSite site = new SPSite("http://sptest:100");
                    SPWeb web = site.OpenWeb();

                    SPList list = web.Lists["Countries"];
                    SPListItemCollection listitems = list.Items;

                    XPathNavigator nav = this.CreateNavigator().SelectSingleNode("/my:myFields/my:Countries", this.NamespaceManager);

                    foreach (SPListItem li in listitems)
                    {
                        XPathNavigator newNode = null;
                        newNode = nav.Clone();

                        newNode.SelectSingleNode("/my:myFields/my:Countries/my:Displayname", this.NamespaceManager).SetValue(li["Title"].ToString());
                        newNode.SelectSingleNode("/my:myFields/my:Countries/my:Value", this.NamespaceManager).SetValue(li["Title"].ToString());

                        nav.InsertAfter(newNode);

                        newNode = null;
                    }

                    nav.DeleteSelf();

                    nav = null;

i get this error

The Web application at http://sptest:100 could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL 


Nour


Viewing all articles
Browse latest Browse all 1404

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>