How do I point a ListFieldIterator to a subweb when ControlMode = Display?
Posted
by Rich Bennema
on Stack Overflow
See other posts from Stack Overflow
or by Rich Bennema
Published on 2010-04-30T16:03:34Z
Indexed on
2010/04/30
16:07 UTC
Read the original article
Hit count: 759
sharepoint
|sharepoint2007
I have a custom page with the following ListFieldIterator:
<SharePoint:ListFieldIterator runat="server" ControlMode="Display" OnInit="listFieldIterator_Init" />
Here is the Init event:
protected void listFieldIterator_Init(object sender, EventArgs e)
{
ListFieldIterator listFieldIterator = sender as ListFieldIterator;
SPContext current = SPContext.Current;
SPFieldUrlValue value = new SPFieldUrlValue(current.ListItem[SPBuiltInFieldId.URL].ToString());
Uri uri = new Uri(value.Url);
using (SPWeb web = current.Site.OpenWeb(uri.AbsolutePath))
{
SPListItem item = web.GetListItem(uri.PathAndQuery);
if (null != item)
{
listFieldIterator.ItemContext = SPContext.GetContext(this.Context, item.ID, item.ParentList.ID, web);
}
}
}
Everything works great if the target List Item is in the same site as the page. But once it points to a different site, all the fields appear, but the values all appear in the following format:
Failed to render "Title" column because of an error in the "Single line of text" field type control. See details in log. Exception message: List does not exist The page you selected contains a list that does not exist. It may have been deleted by another user..
If I change the ControlMode to Edit, the values are displayed correctly. So how do I get it to work while in Display mode?
© Stack Overflow or respective owner