I'm developing a web part in which the Announcements list of a subsite will be displayed on its parent. Here's what I have so far:
XsltListViewWebPart XLV = new XsltListViewWebPart(); SPWeb web1 = SPContext.Current.Site.OpenWeb("clients/FooFactory"); SPList lists = web1.Lists["Announcements"]; XLV.ListId = lists.ID; XLV.ViewGuid = lists.DefaultView.ID.ToString(); this.Controls.Add(XLV);
When I debug, I know it can find the site. I know it can find the list. But, it bombs on
this.Controls.Add(XLV). Here's my RTE:
List does not exist.
The page you selected contains a list that does not exist. It may have been deleted by another user.
Presumably it's because the site that I'm on doesn't know about the List as belonging to THAT site. But, my whole aim is to display the list of another site onto THIS site. What can I do?
Just to Reiterate: The custom Web Part is being displayed on a Parent Site, and is intended to display a list that exists on a subsite which inherits permissions.