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 :)

1 Answer 1


Deep in the ether of the interwebs I discovered this gem: http://blog.falchionconsulting.com/index.php/2007/10/retarget-content-query-web-part/

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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