I have an XSLTListViewWebPart on an application page. Why I use visual studio to deploy it to the development site, it works fine, but when I use central administration to activate the feature on another site, and go to the application page, I get the error "the page you selected contains a list that does not exist."
Can anyone hint as to why this might be happening? I would paste in the web part code, but it's pretty long and I'm not sure it would be helpful.
I can confirm that the list I'm intending to use does exist on the site, but maybe I've got a relative reference to it that's not working properly, I guess. I just can't identify what property that might be. I've checked the TitleUrl
ListID
ListUrl
and ViewGuid
properties and they're all being set properly.
This is in 2010, but I'm not sure the issue is unique to 2010.
Edit: here's one of the web parts. There are actually three on the page, but they're all pretty basic and similar.
<WebPartPages:XsltListViewWebPart runat="server" Description="My List Instance" ListDisplayName="" PartOrder="2" HelpLink="" AllowRemove="True"
IsVisible="True" AllowHide="True" UseSQLDataSourcePaging="True" ExportControlledProperties="False" IsIncludedFilter="" DataSourceID=""
Title="Product Sequences" ViewFlag="8388621" NoDefaultStyle="" AllowConnect="True" FrameState="Normal" CatalogIconImageUrl="/_layouts/images/itgen.png"
PageSize="-1" PartImageLarge="/_layouts/images/itgen.png" AsyncRefresh="True" Dir="Default" DetailLink="{$SPUrl}/Lists/Product Sequences"
ShowWithSampleData="False" ListId="64592f39-d6ae-43d7-b580-4b2b72b350d2" ListName="{64592F39-D6AE-43D7-B580-4B2B72B350D2}" FrameType="Default"
PartImageSmall="" IsIncluded="True" SuppressWebPartChrome="False" AllowEdit="True" ViewGuid="{2D64D56A-4E74-4DE6-94BF-13183A7C378F}"
AutoRefresh="True" AutoRefreshInterval="3600" AllowMinimize="True" WebId="00000000-0000-0000-0000-000000000000" ViewContentTypeId="0x"
InitialAsyncDataFetch="False" GhostedXslLink="main.xsl" MissingAssembly="Cannot import this Web Part." HelpMode="Modeless" ListUrl=""
ID="ProductSequencesList" ConnectionID="00000000-0000-0000-0000-000000000000" AllowZoneChange="True" TitleUrl="{$SPUrl}/Lists/Product Sequences" ManualRefresh="True" __MarkupType="vsattributemarkup" __WebPartId="{2D64D56A-4E74-4DE6-94BF-13183A7C378F}" __AllowXSLTEditing="true" __designer:CustomXsl="fldtypes_Ratings.xsl" WebPart="true" Height="" Width="">
<ParameterBindings>
<ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
<ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
<ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)" />
<ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)" />
<ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)" />
<ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)" />
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
</ParameterBindings>
<XmlDefinition>
<View Name="{2D64D56A-4E74-4DE6-94BF-13183A7C378F}" MobileView="TRUE" Type="HTML" Hidden="TRUE" DisplayName="" Url="{$SPUrl}/SitePages/RecipeManagement.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/generic.png">
<Query>
<OrderBy>
<FieldRef Name="ID"/>
</OrderBy>
</Query>
<ViewFields>
<FieldRef Name="Title"/>
<FieldRef Name="Vessel"/>
<FieldRef Name="Comments1"/>
</ViewFields>
<RowLimit Paged="TRUE">30</RowLimit>
<Toolbar Type="Freeform"/>
</View>
</XmlDefinition>
<DataFields>
</DataFields>
</WebPartPages:XsltListViewWebPart>
And Because the guids change each time it's deployed - I have this utility method, called from the code behind:
// in code behind (Page_Load):
Utilities.ResolveWebPartList("Product Sequences", ProductSequencesList);
the utility method:
internal static void ResolveWebPartList(string listName, XsltListViewWebPart listViewWebPart)
{
using (var site = new SPSite(SPContext.Current.Web.Url))
using (var web = site.OpenWeb())
{
var theList = web.Lists[listName];
if (theList == null)
{
throw new NullReferenceException(string.Format("The specified list '{0}' does not exist in the site '{1}'.", listName, SPContext.Current.Web.Url));
}
listViewWebPart.TitleUrl = theList.DefaultViewUrl;
listViewWebPart.ListId = theList.ID;
listViewWebPart.ListUrl = theList.DefaultViewUrl;
listViewWebPart.ViewGuid = theList.DefaultView.ID.ToString();
}
}