Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3978154
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:00:41+00:00 2026-05-20T05:00:41+00:00

I am having issues with retrieving list items from a different site collection. I

  • 0

I am having issues with retrieving list items from a different site collection. I don’t have issues when trying to recieve list items from within my current site collection. For example, http://myintranet.com/Departments/IT works. But http://myintranet.com/sites/Departments/IT returns an error.

if (!String.IsNullOrEmpty(SiteName) && !String.IsNullOrEmpty(SPContext.Current.Web.Url))
    {
      SPSecurity.RunWithElevatedPrivileges(delegate()
      {
        using (SPSite intranetSite = new SPSite(SPContext.Current.Web.Url))
        {
          using (SPWeb currentWeb = intranetSite.AllWebs["/sites/projects/Physics"])
          {
            SPList postList = currentWeb.Lists.TryGetList("Issues");                

            if (postList != null)
            {
              IssueList.DataSource = postList.Items.GetDataTable();

              IssueList.DataBind();
            }
          }
        } 

      });
    }

I haven’t used any different code to what I normally do when trying to recieve list items. The only difference is that this time I getting list items from another site collection.

Thanks for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:00:42+00:00Added an answer on May 20, 2026 at 5:00 am

    The problem is intranetSite.AllWebs. This will only get SPWeb objects under your current site collection.

    You cannot infer another site collection directly from one site collection.

    Even though /sites/projects LOOKS like chid site collection from /, it;s not. /sites is just a managed path. / and /sites/projects are at the same level of the site collection hierarchy.

    What you need to do is to this:

    if (!String.IsNullOrEmpty(SiteName) && !String.IsNullOrEmpty(SPContext.Current.Web.Url))
        {
          SPSecurity.RunWithElevatedPrivileges(delegate()
          {
    
              using (SPWeb currentWeb = new SPSite("http://server/sites/projects/Physics").OpenWeb())
              {
                SPList postList = currentWeb.Lists.TryGetList("Issues");                
    
                if (postList != null)
                {
                  IssueList.DataSource = postList.Items.GetDataTable();
    
                  IssueList.DataBind();
                }
              }
    
          });
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been having some issues retrieving JSON data from a WCF service application
Having issues referencing $(this) from within a the nested ajax 'success' function... I know
Having issues calling the ReportingService2005.FindItems() method from within powershell v2. $rs = New-WebServiceProxy -Uri
I having issues getting Django to work with settings.py at different location I have
Having issues with screen progress. I have a screen displaying information from a database.
Am having issues with printing different sized PDF's using GhostScript (V9.05). The PDF in
Im having issues getting this to work, maybe its not even possible? I have
I'm having some performance issues since a DB was moved from SQL2000 to SQL2008.
Hey guys and gals I'm having some major issues trying to get my application
Having issues getting myself started on MVC3 Trying to define a simple route here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.