Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
add comment

2 Answers

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;
gv.DataBind(); 

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

share|improve this answer
add comment

Your Answer

 
discard

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.