title: How can I get a Content Query Web Part to show items from more than one type of list?
body: <p>I am trying to use a Content Query Web Part to create a "What's New" page in Sharepoint 2010.  The goal of this page is to display any documents that have been uploaded in the last 14 days.  The trick is that these documents could belong to any number of lists that are defined in any number of list definitions.  These are custom list definitions based on custom content types.  We do have a base content type that each of our custom content types inherit from.  They are also all part of the same content type group.  I have determined that it is not possible to use the SP UI to set up the CQWP to return items from multiple list types, since one of the required query fields is list type.  So - I'm attempting to use CAML to define this CQWP and this is where I'm having trouble.  My end goal is for the CAML to be defined in a site definition (onet.xml file) but I've also not had any luck with uploading a .webpart file from the SP UI.   I have found several articles that explain how this should be done but haven't been able to get the suggested solutions to work.  This <a href="http://msdn.microsoft.com/en-us/library/aa981241.aspx" rel="nofollow">MSDN article</a> tells me it should be possible using the ListsOverride element.  This is how the article tells me to do it:  </p>
  
  <pre><code>&lt;![CDATA[
            &lt;Lists BaseType="0"&gt;
            &lt;/Lists&gt; ]]&gt;
  </code></pre>
  
  <p>Since I'm looking for Document Libraries I would use a base type of 1 rather than 0.</p>
  
  <p>I have been unable to determine the syntax for what that would actually look like from within the onet.xml file so I thought I'd start with trying to get it uploaded as a .webpart file.</p>
  
  <p>This is what the ListsOverride element looks like:</p>
  
  <pre><code>&lt;property name="ListsOverride" type="string"&gt;
      &lt;![CDATA[&lt;Lists BaseType="1"&gt;&lt;/Lists&gt;]]&gt;
  &lt;/property&gt;
  </code></pre>
  
  <p>However - as soon as I upload a .webpart file with this in the CAML and add the webpart to a page I break that page in Sharepoint.  This is what I get:  </p>
  
  <p>Server Error in '/' Application.
  Attempted to use an object that has ceased to exist.</p>
  
  <p>Research on that error points me to code that disposes of an object such as SPContext.Current.Web but I don't even have any code at all here.  It almost looks like the CQWP has a bug in it.  OR - I'm either not formatting that CAML properly or maybe I need to change something in a different element in the CAML?</p>
  
  <p>I am running Sharepoint 2010 SP1 with all the latest patches. (I believe)</p>
  
  <p>I've tried several other formats but without luck. </p>
  
  <p>I tried getting rid of the embedded CDATA tags like this:</p>
  
  <pre><code>&lt;property name="ListsOverride" type="string"&gt;
      &lt;Lists BaseType="1"&gt;&lt;/Lists&gt;
  &lt;/property&gt;
  </code></pre>
  
  <p>But then Sharepoint won't let me upload the .webpart file.  (Invalid .webpart file)</p>
  
  <p>The format with the embedded CDATA tags seems to be the only way it lets me upload the file.</p>
  
  <p>I've tried (just for the sake of narrowing down my issue) to specify specific lists like this:</p>
  
  <pre><code>    &lt;property name="ListsOverride" type="string"&gt;
  &lt;![CDATA[&lt;Lists&gt;&lt;List Id="{5a2f79bb-cc82-4171-88ac-65f20e7b5fa8}" /&gt;&lt;/Lists&gt;]]&gt;
  </code></pre>
  
  <p></p>
  
  <p>That doesn't break the page but the webpart gives me less than useful error on the page (Unable to display this Web Part)</p>
  
  <p>I'm not 100% sure that I used the appropriate GUID in that attempt.  I got it from looking in the server explorer in Visual Studio (Under Lists and Libraries >> Document Libraries >> My List Type.  (I got the GUID from the Id property)</p>
  
  <p>I should mention that I am fairly new with Sharepoint development.  I would have hoped that something seemingly so core to what Sharepoint does would be much easier than this.</p>
  
  <p>Can someone please point out what I am doing wrong?   Maybe I'm going about the whole thing in the wrong way?   I appreciate any help that anyone can give me!</p>