SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

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

This might be foolish question, but I am new to the SharePoint 2010 environment. I want to fetch data from a SharePoint list using the CQWP web part. I then want to use this web part as the data source for another web part that can show me this SharePoint list data.

Can I do this? How can I approach this?

share|improve this question

In short, I don't think that you can use it as a datasource directly. You can change it's appearance - and there are a lot of articles about how to do that. However, actually using it as a data source is a slightly different thing.

Internally, the Content Query Web Part is built around the SPSiteDataQuery object. You can use this to query in the same way as th CQWP, and this will get you a DataTable. You can then bind this to the controls that you want to. E.g.:

SPSiteDataQuery query = new SPSiteDataQuery();
query.Query = "<Where> ... your query here ... </Where>";
// ... Configure your query - scope, types of list, etc.
query.Webs = "<Webs Scope='SiteCollection' />";

DataTable dt = web.GetSiteData(query);

// now use as you wish. E.g.
SPGridView gv = ...
gv.DataSource = dt;

If you mean how do you use this with web part connections - again, I don't think you can.

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.