sharepoint-2010site-definitionlist-definition

Listview webpart in site definition makes it all fail


I have made a listdefinition which I've put in to a web scoped feature which I've added to WebFeatures in my sitedefinition. In my sitedefinition I've added a list view web part which shall display the list created through the listdefinition. My issue is that when I add the list's name to the List property in the list view web part like so:

<View List="OrderList" BaseViewID="1" WebPartZoneID="Footer" WebPartOrder="2">
</View>

the process of creating the new sub site fails because of this alone. I have 2 other lists which is added to the sitedefinition in the exact same way

<View List="Documents" BaseViewID="1" Type="HTML" WebPartZoneID="Footer" WebPartOrder="1">
</View>

<View List="108" BaseViewID="3" WebPartZoneID="Footer" ContentTypeID="0x012001" WebPartOrder="4">
</View>

The only difference is that those 2 lists are standard sharepoint Documents library and Discussion board. If I remove the custom list's list view web part the entire flow works correctly, but as soon as I add it the entire thing fails.

I've created the listdefinition through VS2010 own listdefinition template etc and I haven't touched a thing. Only changed the name in the List Instance and made sure everything matched in the Elements.xml and Schema.xml files


Solution

  • What is the Url attribute of your ListInstance?

    Because the List attribute of the View element must match the Url from the ListInstance. For example, if your ListInstance is defined as:

    <ListInstance
        FeatureId="00000000-0000-0000-0000-000000000000"
        TemplateType="0000"
        Title="My Test List"
        Url="Lists/OrderList">
    </ListInstance>
    

    then your View must be:

    <View List="Lists/OrderList" BaseViewID="1" WebPartZoneID="Footer" WebPartOrder="2">
    </View>