【发布时间】:2011-06-29 09:01:13
【问题描述】:
我在从其他网站集中检索列表项时遇到问题。尝试从当前网站集中接收列表项时,我没有遇到问题。例如,http://myintranet.com/Departments/IT 有效。但是http://myintranet.com/sites/Departments/IT 返回错误。
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();
}
}
}
});
}
在尝试接收列表项时,我没有使用与通常使用的代码不同的代码。唯一的区别是这次我从另一个网站集获取列表项。
感谢您的帮助!
【问题讨论】:
标签: list sharepoint-2010 web-parts