tags:

views:

240

answers:

1

I am trying to create a web part which will list all the items from the site collection i.e. from each web site's document library. I am using the following code.

        SPWeb web = SPContext.Current.Web;
        SPSiteDataQuery query = new SPSiteDataQuery();

        //Ask for all lists created from the document library template.
        query.Lists = "<Lists ServerTemplate=\"101\" />";

        // Get the Name field.
        query.ViewFields = "<FieldRef Name=\"Title\" />";                               

        // Set the sort order.
        query.Query = "<OrderBy>" +
                          "<FieldRef Name=\"Created\" Ascending=\"False\" />" +
                      "</OrderBy>";

        // Query all Web sites in this site collection.
        query.Webs = "<Webs Scope=\"SiteCollection\" />";

        DataTable dt = web.GetSiteData(query);
        DataView dv = new DataView(dt);

My site collection contains nested sub sites and work spaces with different document libraries. The web part is rendered perfectly but it only shows the column Title because it is specified in ViewFields.

Is it possible to show the column Name (linked to document with edit menu), so that each item will be appeared as hyperlink and on click of this link it will open the item in respective application e.g. in Microsoft Word 2007.

Please help me in this regard.

A: 

Try using SPGridView. An example is located here.

Alex Angas