Click here to Skip to main content
15,891,763 members
Articles / Productivity Apps and Services / Sharepoint / SharePoint 2013
Tip/Trick

SharePoint Lists and Libraries

Rate me:
Please Sign up or sign in to vote.
4.57/5 (4 votes)
21 Dec 2015CPOL9 min read 9.8K   2   1
The article gives brief on how to create and manage Sharepoint web applications using SharePoint Central Administration Website.

Introduction

In this article we are going to look at the following topics:

  • Lists
  • Columns
  • Site Columns
  • Content Types
  • Lists definition
  • Lists Instance
  • Site definition

Lists

In SharePoint, the data is stored in the forms of Lists/Library, which in general means they are equivalent to tables in a database (at least, for the time being we can consider them as such).

Lists in SharePoint are generally used to save data in the form of records/items and Libraries are used to store documents and other files. One of the main purposes of SharePoint is it can be used as Repository for Storage of files in a central location which can be shared among teams. When we talk about storage of data/files or repository, in SharePoint we are actually talking about the content database, as all the content of SharePoint is stored in a database which is called the "content database."

The following steps are used to create Lists in the SharePoint:

  1. Click on Site Actions Ribbon available on the top right side of the site.

    Image 1
  2. Click on Site Contents, it navigates to the Site Contents page where we can find all the available Lists/Libraries.

    Image 2
  3. There is an option called "add an app," on clicking on that it takes us to the landing page of List Templates from which we choose the required list template

    Image 3
  4. Choose Custom List from the available list templates, and enter the Name as "Employeedetails" in the pop up window and click on create.

    Image 4
    Image 5
  5. This completes the creation of SharePoint List. The created SharePoint list is available in the View all Site Contents page of the SharePoint Site.

Columns

Columns in SharePoint are available as two types Lists/Library Columns and Site Columns. We can create columns in SharePoint in the same manner as we create the columns in a database table. Columns are used to hold the data and each column has a specific data type.

The following steps are used to create columns in a SharePoint Lists/Library using SharePoint UI.

  1. In this Section we can create the columns to the above created "Employeedetails" List.
  2. Navigate to the "Employeedetails" list and on the ribbon click on Create Column or Click on List Settings and got to Create Column Page.

    Image 6
  3. In the Create New Field Page we have the following options:
    1. Name
    2. Data Type
    3. Description
    4. Maximum no of characters and
    5. Column Validation.
  4. Give the appropriate values for the columns and repeat the steps 1 to 3 to create different columns to the Employeedetails lists.

    Image 7
  5. For our example we'll just create the following fields. a) EmployeeId – Integer b) EmployeeName – Single Line of text. c) Visadetails – Single Line of text. d) ProjectName – Single Line of text.
  6. We will learn about Column Validation in the upcoming articles of the series.

Site Columns

As we have already discussed, we can create Columns within a particular List/Library or across the sites in Site Collection. The Columns created at the site level are called site columns and can be used within a Site Collection for available Site and Sub Sites.

As per best practices, we generally go for Site Columns when compared with list columns, as Site Columns have multiple advantages. Site Columns are reusable, easily available for searching, can be used with search web parts like content query web part, easier for migration, also provides effective structure and are helpful in reorganizing the structure of the site.

The following Steps are used to create Site Columns:

  1. Click on the Site Actions => Site Settings.

    Image 8
     
  2. This will navigate to the site settings page in the Site Settings Page, under the "Web Designer Galleries" Section, click on Site Columns.

    Image 9
  3. Site Columns page is displayed with all the available site columns grouped together.

    Image 10
  4. Now click on create and the page is redirected to the "Create Column" page: Provide the following options for the column to be created:
    1. Name (EmployeeId)
    2. Data Type (Integer)
    3. Group (Check the "New Group" radio button and give the name of the group as Employee).
    4. We can choose the options for unique and mandatory for the created field.

    Image 11
  5. Repeat the above steps to create EmployeeName and Visadetails fields. Except at 4th step instead of creating new group choose the existing "Employee" group, which is already being created.

    Image 12
     

Content Type

Content Types in SharePoint are used to hold the collection of Site Columns. In a broader meaning: Content Types are reusable settings which enable us to manage the Meta data and behavior of the content.

The following are the steps used to create content types:

  1. Click on Site Actions Ribbon => Site Settings.
  2. Go to Site Settings page, under "Web Designer Galleries," click on Site Content types.

    Image 13
  3. Site Content Types page shows all the available Content Types Grouped together.
  4. We can filter the content types based on group by using the drop down available at the top right of the page.

    Image 14
  5. Now to create new content type click on "Create." This redirects to the New Content Type page, where we can give the name, description, select parent content type and we can add the content type to the existing group or we can create new group.

    Image 15
  6. The Created content type is available in the Site Content type gallery under the respective group.
  7. Once the content type is created, we can go ahead and start adding the columns to the content type.
  8. The completed content type looks as below:

List Definition and List Instance

List definition helps us to create a new custom list based on the existing list type, from which we can create multiple instances of the same list. While we can create a new custom list from UI without using Visual Studio and save the list as a template to create multiple instances, the list definition helps us in deploying custom lists to multiple environments/servers. The other advantage of using list definition is it helps in easier customization of List Forms.

Site definition

Site definition helps us to create a new site from the Site Actions ribbon. We can create Site definitions using Visual Studio and deploy it to the server. Once deployed, the site definition is available in the site template from which we can choose the site definition and create a new site.

Site definition helps us to choose all the components required for a site like Lists, Libraries and Features and so on.

Activity Developing site definition and adding Site Columns, Content types and lists to the Site definition using Visual Studio.

Scenario

For example, consider a simple situation where we are supposed to save the details of employees in a list. Now in the same list if we want to have different fields for Onsite Employees and Offshore Employees then we achieve this with the help of Content types. So we will create two content types one for Onsite Employee and the other for Offshore Employees and add these two Content types to the List.

In this demonstration we will create a simple Site template which holds the Employee details list. As part of our example we are creating only limited columns you can add more columns, list and content type as per the requirements by repeating the below steps.

Site Columns

Method 1

Creating Site Column using Visual Studio:

  1. Click on Start Menu and Open Visual Studio in Administrator mode.
  2. Create a new project by clicking on New Project option in the Visual Studio. Choose Empty SharePoint Project from the template window and give Project Name as SPSTraining.

    Image 16

  3. Enter the SharePoint Site URL and Choose "Deploy as Farm Solution" option. Click on validate button to validate the site URL and then click on Finish.

    Image 17

  4. Right click on the Solution in the Solution Explorer and click on Add New Item and choose Site Column from the template window.

    Image 18

    Image 19

  5. The following lines of code is generated in the XML file created.
    XML
    <?xml version="1.0" encoding="utf-8" ?>
    <elements xmlns="http://schemas.microsoft.com/sharepoint/">
                   <field id="{7c5d5cc0-17e6-4678-afc3-79b0fbea7e95}"
           name="EmployeeName"
           displayname="Employee Name"
           type="Text"
           required="FALSE"
           group="Custom Site Columns">
                 </field>
    </elements>
    
  6. Repeat the above steps to create the following Site Columns.
    1. EmployeeName.
    2. EmployeeId
    3. Visadetails
    4. ProjectName

Method 2

We can also create the Site Columns in Visual Studio by using Empty Element. The following steps show the same.

  1. Right click on the solution in the explorer and click on Add New Item and choose Empty template from the template window.
  2. Give the name to the template as Employee Fields.
  3. Click on the Elements.xml file and add the below code
  4. Repeat the above steps to add required columns.

Content Types

The following steps are used to create the Content type using Visual Studio:

  1. Right click on the Solution in the Solution Explorer and click on Add New Item and Choose Content Type from the template window.
  2. Add the columns in the created content type and choose the required data type for the created fields as shown below.
  3. Repeat the above steps to create the content types "OnSiteEmployees" and "OffShoreEmployees"

The following table shows the tables of content types with their respective columns.

  1. Off Shore Employees
    1. Name
    2. Designation
    3. Id
    4. Department
  2. On Site Employees
    1. Name
    2. Designation
    3. Id
    4. Department
    5. Visa details.
Content Type Columns
1. Off Shore Employees
  • a) Name
  • b) Designation
  • c) Id
  • d) Department
2. On Site Employees
  • e) Name
  • f) Designation
  • g) Id
  • h) Department
  • i) Visa details.

List definition

The following steps are used to create list definition using the visual studio.

  1. Right-click on the Solution in the Solution Explorer and click on Add New Item and Choose List from the template window.
  2. Give the name as Employeedetails and click on Add. This creates Employeedetails list definition and Employeedetails list instance.
  3. Click on the Content Types button in the List and the existing content types which we have created earlier and choose OffshoreEmployees as default Content type.

Site definition

We can create a site definition and the above create fields, content types and lists to the site by using the site definition.

The following are the steps are used to create the site definition and add the lists to it:

  1. Right click on the solution in the solution explorer and click on Add New item and choose Site definition template from the template window.
  2. Give the name as Project Portal and click on Add.
  3. Once the site definition is added the following files are added to our solution. "default.aspx" page, onet.xml file and webtemp_ProjectPortal.xml.
  4. Onet.xml file is used to specify the lists, libraries, features (Site and Web), Navigation items, files and other modules available in the site.
  5. Now right click on the feature in the explorer and click on properties. Properties window is opened; now double click on the feature to open the get the properties of the feature.
  6. From the properties window copy the Feature Id
  7. Add a new tag called Feature under WebFeatures tag and paste the id attribute value, which was earlier copied.
  8. This completes our sample site definition.
  9. Now this solution is ready for deployment.

Points of Interest

This article is part of series of articles on Sharepoint for beginners.

Below are the list of articles on "Sharepoint for beginners."

  • SharePoint - Web Application Management
  • SharePoint Lists and Libraries

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Collabera
Singapore Singapore
S V Sai Chandra is a Software Engineer from Hyderabad Deccan. He started Embedded Programing in his college days and now he is a Web Developer by Profession. He Loves coding and his passion has always been towards Microsoft Technologies. Apart from coding his other hobbies include reading books, painting and hang out with friends is his most favorite past time hobby.
He blogs at
http://technowallet.blogspot.com
Technical Skills:
C#,Ado.Net,Asp.Net,Sql Server,JavaScript,XML,Web services.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Santhakumar M22-Dec-15 4:05
professionalSanthakumar M22-Dec-15 4:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.