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

I can't figure out how to create a solution in Visual Studio 2010 that will allow me to alter existing lists in a SharePoint 2010 site. Specifically, I want to add a new column, which contains a small icon, to existing document library lists. I want to be able to take an action when someone clicks on one of the new icons. I also want this new column to become part of the default view for new document library lists. All of this needs to be easily deployed to a SharePoint 2010 site via a .wsp file.

Extensive searching on Google has shown how to create new lists and new column types, and how to programmatically add columns to one of the new lists, but not how to modify all existing lists. (I have seen some code snippets that look promising, but am not really sure where to put them or if it's applicable to a .wsp file.)

I'm brand new to SharePoint, so any pointers towards a solution would be much appreciated. Thanks!

share|improve this question

4 Answers 4

The only way you're going to be able to add a column to all currently existing document libraries is to modify the Document Content Type, which isn't a recommended customisation (purely because any future service packs may override any and all changes you make).

If you're wanting users to be able to perform an action for each item in a list, then you could probably look at adding a Custom Action to the Edit Control Block (ECB) menu (which appears when you click on the arrow to the right of a document's title).You can apply this customisation to Lists of a specific List Type, and in your case you'd tie it to the Document Library List Type.

(I've capitalised the important words to help you on your Google Searching :) )

share|improve this answer
    
Thanks for the help! I've been re-tasked to something else for a bit, but will be sure to try this when I get back to SharePoint, and say how it goes. –  user1608 Oct 13 '10 at 16:48
    
I think an ECB customization is the best solution. –  Steve P Dec 7 '10 at 20:30

You can go with feature receiver approah here. So you will have two parts of in solutions:

  1. Code that adds your columns to a given library object and to the default view of the library.
  2. A feature receiver that gets the collection of all the document libaries in the current web and further calls the method in #1 by suppllying the currently iterated SPList object.
share|improve this answer
    
As in the comment above, thanks! I'm looking forward to being able to try these out. –  user1608 Oct 13 '10 at 16:50

I would do it in powershell.

Check this out

share|improve this answer

Basicly you could also just itterate through all the lists in your web. Check wether its a Document Library or not, incase it is... Add a new column... This can be done using vs2010 or ps. Tho editing the Content Type might be better :-)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.