What is the best way to create an Html Table out of a sharepoint list in a Web Part? - sharepoint

I want to create a deployable .wsp Web Part and I want to fetch a Custom List and show it in an Html Table inside that web part.
I know how to create a .wsp web part, and I can also create the table overriding the RenderContents or CreateChildControls methods of WebPart class.
But I want to know the easy and best method for outputting an Html Table in a WebPart.
Should I use a UserControl so that, I can add any Asp.Net controls inside it and then load it in the Web Part ??
Please tell me any solutions ?

Puneet i would recommend using Data View webparts which uses xslt to customize the view in which a list data is rendered.
You can take help of SharePoint Desginer to add a Data View Web Part.
http://www.lcbridge.nl/vision/2009/dvwp.htm

Check out this video. It shows how to build a Visual Web Part (one that uses a user control for UI) in Visual Studio 2008 and shows how to bind data from a list to a GridView control.
http://www.vimeo.com/11285888

Related

How to add a webpart to a listview in sharepoint 2010?

I have to add a "Content Editor" web part to a list view. The "Content Editor" is required to implement some java script and a html textbox.
The problem is that after adding the web part to the list view the dropdown to switch your current view gets lost. It doesnt matter where you add the web part or if you try it with the designer or IE.
Do you have any ideas on how to solve this? Or is there another way to implement java script into a listview without adding a new web part?
This is the dropdown I mean:
Its a known issue with SharePoint 2010.
You can modify the page using SharePoint Designer to put it back.
http://vintentou.wordpress.com/2010/08/03/missing-dropdown-menu-for-choosing-of-views/
My company has also produced a free add-on that will do this for a whole site.
http://www.pentalogic.net/sharepoint-products/free-stuff/view-rescue

Changing the source of a Sharepoint List View

Effectively I am looking to change the viewed Document Library within an exsisting List View Web Part from 'Document Library #1' to Document Library #2'. I want to do so without having to re-create the entire web part (e.g. settings & views) as I would have to do this multiple times.
Sharepoint version is 2007 and Sharepoint Designer is not avaliable.
Context: I am currently building a Sharepoint area which will consist of multiple ASPX pages all based off an original layout. This layout includes a List View web part that directly views a Document Library.
Each ASPX page has a Document Library attributed to it (e.g. Page1.aspx and DocLib1), which I wish to display within this List View web part.
Page1.aspx was setup just fine (effectively the original). When setting up Page2.aspx as a direct copy of the first, I am unable to change the List View from DocLib1 to DocLib2 as there seems no option to do so.
The list view web part isn't easily customizable unless you can edit the xml for the web part and change some guids. If you want to be able to change the source list through the browser you will need to use a different web part - the content query web part is an out of box option, though obviously that is quite different from the standard list view.
You may also be able to do something with with list templates - if you can use a custom template instead of the standard document library template, you may be able to alter AllItems.aspx to do what you need.

Creating Dynamic Sitemap in SharePoint

I have developed a publishing portal in sharepoint.I have a requirement wherein I need to create sitemap for the entire web application.
This should be dynamic, in the sense, whenever we update the contents of any given page in our web application, it should be reflected immediately in the sitemap page. What are the possible ways to achieve this and which is the best possible solution considering the scalability and easy configuration?
Thank you.
If you don't want to use a custom webpart, you could use normal navigation list to create your sitemap and it is automatically updated. You only need to style it in a way to resemble some kind of sitemap.
Here are some links to get you started with customizing your navigation:
Custom Navigation in SharePoint - The Full Monty
How to: Customize Navigation
Also there is the portal site map which provides the data source for your custom menu. Just read up on custom navigation and stuff like PublishingNavigation:PortalSiteMapDataSource and SharePoint:AspMenu.
There is a nice PowerShell script to create a sitemap for SHarepoint 2010, if you want to submit your sitemap to Google: Generate A Sitemap For SharePoint 2010 Using PowerShell'.
You can also install and customize the SharePoint Web part ("Table of Contents") to your liking. Read up on it here...
Take a look at our ECS product, it is close to what you need
http://www.infowisesolutions.com/product.aspx?id=ECS
It was built as a system of cross site collection navigation, with security trimming and permissions inheritance between site collection.

Load a web part before other

I am stuck with a problem. I am having tool part where I get all the Lists present in the Site.
I have other web part which should get the selected List in the tool part.
I see that the web part is loaded first then the tool part. so the web part is unable to the List selected in the tool part.
Please note that the text box is in a User Control.
Please help me.
I have looked at your code and found the following:
First things first. You need to move AWAY from using ToolParts and the SharePoint native webpart. they are deprecated and are a remnant from SPS2003. In MOSS / WSS 3.0 you can and should use the ASP.NET WebPart.
Secondly, I think you are mixing things up. The ToolPartGetLists is not a toolpart, it is a webpart, that in itself loads the CustomToolPart, which in turn allows you to select a list.
This toolpart is only shown when you edit the shared webpart in the UI. The list you select is then persisted to the SelectedList property of the webpart using the toolpart.
The connected webpart then tries to read the SelectedList property I guess.
Like I said, I could go and try to fix the code for you, but it is not the way to go, you really (REALLY) need to switch to ASP.NET WebPart based webparts. The native sharepoint one WILL be fased out in the (near) future.
Here you can find an example, with code! (scroll to bottom for download link). As a bonus, it uses the built in sharepoint listpicker
I don't know of any way you could control the load order of elements (web parts) on the same page.
Sounds more like you want to have your second web part (the display of the lists) have a "default" when the page loads--which could be empty. Then it would be changed to the selected list only when the user clicked a new selection in the other web part (the list of lists).

Sharepoint: Best way to display lists of non-Sharepoint content with "compatible" UI?

I've built a web part for Sharepoint that retrieves data from an external service. I'd like to display the items in a way that's UI-compatible with Sharepoint (fits in with its surroundings.)
I'm aware of the "DataFormWebPart" but was unable to get one working properly. It requires a valid DataSource and I was unable to build one from the results of a web service call... Part of the problem is that my web service wrappers don't expose the XML return info, rather I have a bunch of deserialized objects. There doesn't seem to be an easy way to turn actual objects into a datasource, or populate a "generic" datasource from object data.
I could use an SPGridView to get the same UI, but the grid control doesn't have much in the way of smarts -and- it forces every field into its own column. I'd prefer to render each list item as a single cell with complex rendering (for instance the way that StackOverflow shows its lists of questions.) I'd also like to get as much of the Sharepoint-standard UI as possible, such as the sorting, filtering, and paging controls.
So, first: Has anyone here written a Sharepoint control that does this, and if so do you have sample code to share? If not: am I overlooking some useful control, whether MS-supplied or available in an external library?
Thanks!
Steve
Sharepoint: Best way to display lists
of non-Sharepoint content with
“compatible” UI?
Take a look at the built in sharepoint web controls:
Microsoft.SharePoint.WebControls Namespace
It contains all the controls used in sharepoint. I'd tell you more, but the documentation is very thorough.
Problem with SharePoint is that there are a bunch of different ways to do this. If your data is not changing too often and is not overly large it may be worth considering entering it into a list for display.
If you have the Enterprise licence it may be worth getting your data into the BDC and using it there.
you may have to convert the objects into xml or use the serialised objects with the XML webpart for display. This still has the issue of custom rendering using XSLT.
Here's a great article that explains how to configure BDC connections to web services using the BDC Definition Editor:
Creating a Web Service Connection by Using the Business Data Catalog Definition Editor
http://msdn.microsoft.com/en-us/library/bb737887.aspx
The best way to do this IMO is to make a Web Part. As a Web Part the UI will be automatically rendered to be the same as the theme the site is using (unless you override it) and it will be able to be placed anywhere by anyone with admin privileges.
Tutorial on making a Web Part
Tutorial on packaging and deploying a Web Part
Example Web Part Source Code
You could create a custom web part and use an SPGridView. You say you don't like it, because it forces every field into its own column, but that's not true. You can create a template (ITemplate) for every column and fully customize what's shown inside it, just like you would using a normal ASP.Net GridView. Using this approach I've added the little "New" images right next to a list item's Title, just like SharePoint does itself.

Resources