.NET Tips and Tricks

Blog archive

Create a SharePoint List in Visual Studio 2012

The problem with creating SharePoint WebParts or pages in Visual Studio is that most of your code will depend on some other resource in your SharePoint site -- typically, a List. If the List has to be deployed as part of installing your application, you have three choices: define your list in CAML (ugly), create your list in your development SharePoint site and export it to your Visual Studio project (awkward, but my preferred method), or create the List in the SharePoint site through the SharePoint UI (not a bad plan, provided you're only installing to one site and you remember to do it).

With Visual Studio 2012 and SharePoint 2013, you have a better choice.  After installing the SharePoint 2013 Development Tools, you can create an empty SharePoint project and add a SharePoint List to it (the SharePoint project and project item templates are now listed in an Office/SharePoint category in the Add Project Item category). When you add a List project item, you get a chance to pick the template you want to base your new List on, either as a customizable or non-customizable List.

If you pick a customizable template, you can select which columns from the template you want to use, change the display names for columns or add existing Content Types to your List. You can also pick which Views you want to make available to the List, set the title and URL, and specify whether the list appears in the Quick Launch menu (or is hidden from the browser). It's not as powerful as the List editor built into SharePoint, but it's pretty good.

Here's my tip: I'm not saying that building Lists in Visual Studio is a "good enough" reason to upgrade to either SharePoint 2013 or Visual Studio 2012. But it's a compelling one.

Posted by Peter Vogel on 03/06/2013 at 9:03 AM


comments powered by Disqus
Upcoming Events

.NET Insight

Sign up for our newsletter.

I agree to this site's Privacy Policy.