I have an SP 2010 web part that access list data using LINQ. The data and the web part currently live on the top-level site. Would I be able to easily access that data in a different web part from a direct subsite? When I say easily, I mean without a total overhaul of the code.

1 Answer 1


Yes. You can get the SPWeb using OpenWeb() method and then pass the SubSiteName

using(SPWeb web = sites.OpenWeb("subsiteurl"))
  • Wouldn't I want to be opening the parent web? This code would be running on the subsite.
    – gsmith140
    Commented Dec 1, 2014 at 15:30
  • Ok in that case you can pass the parent web url to openWeb method Commented Dec 1, 2014 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.