SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Webpart that extends the content query webpart, that is currently pointed to List X. On the click of a button I want that webpart to be changed to point to List Y.

This seems like a very simple requirement, but it apparently isn't :) Does anyone know how to do this?

I have tried:

  • Changing the ListGuid property
  • Changing the ListName property
  • Changing ListOverride property (I didn't do this correctly, as it just threw an error :) )

Any help would be greatly appreciated :)

share|improve this question
up vote 0 down vote accepted

Deep in the ether of the interwebs I discovered this gem:

To solve the problem the following code is required:

//set the web url    
cqwp.WebUrl = list.ParentWeb.ServerRelativeUrl;
//set the guid of the list
cqwp.ListGuid = list.ID.ToString();
//set the list title
cqwp.ListName = list.Title;

This allows changing the list the CQWP is pointing to :)

I hope this helps someone!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.