GS80

Hi,

Is there any way that i can connect to a list view which is contained in a sub site so that i can display the contents on my top level site. At present there is a Helpdesk template implemented as a sub site of the main Sharepoint Environment. I would like to be able to show the Service request list on this page so that i can filter calls based on the logged in user. This would effectively show users an help calls raised by themselves and their status at a glance.

Any help would be much appreciated,

Grant



Re: SharePoint - Development and Programming List View Web Parts

MKeeper

It might be possible to get hold of the SPView object from the SPList in a custom web part.

You could then call one of the render methods of the SPView and spit the results out in the Web Part's Render method






Re: SharePoint - Development and Programming List View Web Parts

GSwan

Hi MKeeper,

Thanks for the response.

I actually have just managed to partially sort the problem. I have set up a Data View web part in SPD2007 on the default page and linked this to a list from the other site. This has allowed me to display the relevent data on the front page. The only problem i have encountered is that this web part seems to be only visible to the user who set it up. I have created this with my Sharepoint admin account, but when accessing from a normal user account the web part doesn't show.

Can you help with why this would be the case

Grant





Re: SharePoint - Development and Programming List View Web Parts

MKeeper

You might find that there is an even easier way.

Try using a "Content Query Web Part"

You can use this to display information that is rolled up from sub-sites.

You can even use it to display information from multiple lists or multiple content types if you wanted

(for example .. show all Announcement Posts from every sub-site).

I'd give that a go before trying to build something custom.

It also supports XSLT output, so you can completely re-format the look and feel of the webpart if you wanted.






Re: SharePoint - Development and Programming List View Web Parts

DaveM.

The List View webpart is going to be just rendering a specific View of a List. You can get the SPView object for any view (by iterating the Views Collection, or retrieving it by name directly - as shown below) and use the RenderAsHTML method to get the view as HTML in its entirety. You can then just write the HTML out in your webpart. You can use the DefaultView property to determine whether the view is the default.

If you just want to get the items shown by the View and handle rendering yourself, you can do something like the following:

SPView newView = list.Views["Dave's View"];

SPListItemCollection lic = list.GetItems(newView);

foreach (SPListItem itm in lic)

{

// Render fields from itm as needed here...ex: output.Write(itm["Title"] + "<br>");

}

Either way works, it just depends on your needs.

-Dave





Re: SharePoint - Development and Programming List View Web Parts

GSwan

Thanks for this,

I cannot try this at the moment but will give it a go when i'm back in the office. Thanks very much for the input.

Regards,

Grant