How to Read from SharePoint 2013 List in 6 Ways

Suppose we have SharePoint 2013 and contains a list called “Users”

Now, there are 6 ways to ready the items for this list:

  • SharePoint 2013 Object Model (C#)
  • Client Side Object Model (CSOM)
  • SharePoint 2013 Web Services
  • REST/OData
  • Power Shell
  • LINQ

First, we need to install Microsoft Office Developer Tool for VS 2012 from this link,

because the VS 2012 come without and project for SharePoint 2013

After installing this your VS new project window will be like:

SharePoint 2013 Object Model (C#)

In this example I will create a new project of type “SharePoint 2013 – Visual Web Part”

In the user control, add a GrivView:

<asp:GridView runat=”server” ID=”grvUsers” />

In the Page Load event write the following code snippet

using (SPSite site=new SPSite(SPContext.Current.Site.Url))


using (SPWeb web=site.OpenWeb())


SPList list = web.Lists[“Users”];

grvUsers.DataSource = list.Items.GetDataTable();




  • Right click on the project and deploy it
  • Go to any SharePoint page and edit the page
  • Insert your web part into your page from “Custom” group
  • Save and close the page

Client Side Object Model (CSOM)

CSOM is a good choice for running a console or windows application on the end user machine and interact with

SharePoint 2013

Create a new project of type “Console Application”

For this, we need to add the following references:

  • Microsoft.SharePoint.Client
  • Microsoft.SharePoint.Client.Runtime

In the Main method write:

ClientContext cc = new ClientContext(“http://sp2013:2000&#8221;);

Web web = cc.Web;

List list = web.Lists.GetByTitle(“Users”);

CamlQuery caml=new CamlQuery();

ListItemCollection items = list.GetItems(caml);




foreach (Microsoft.SharePoint.Client.ListItem item in items)





SharePoint 2013 Web Services

To read from SharePoint list using web services and jQuery, use

And for full documentation follow this link$().SPServices&referringTitle=Documentation

  • Copy the following JS files to SharePoint layouts “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS”
    • jQuery
    • SPServcies
  • Open SharePoint Designer 2013
  • Open the your site collection
  • Go to your master page
  • Open it and write the following scripts

<script src=”/_layouts/15/jQuery.js” type=”text/javascript” ></script>

<script src=”/_layouts/15/jQuery.js” type=”text/javascript” ></script>


operation: “GetListItems”,

async: false,

listName: “Users”,

CAMLViewFields: “<ViewFields><FieldRef Name=’Title’ /></ViewFields>”,

completefunc: function (xData, Status) {

$(xData.responseXML).SPFilterNode(“z:row”).each(function() {





Power Shell

In Power Shell you can use the following script:

$web=Get-SPWeb http://sp2013:2000




You use for-each in Power Shell to iterate through all items.

foreach ($item in $list.Items)

{Write-Host $item.Title}


For using REST you have two options:

  • jQuery
  • C# (HttpRequest & HttpResponse)

For REST reference follow this link OData in SharePoint 2013 – Lists and Items


To use LINQ, we will use SPMETAL

This will generate a CS file in C:\

Add this file to your application (Console or Windows)

Also, you need to add the following assembly

  • Microsoft.SharePoint.Linq

  • Add the generated class in Power Shell script to your project
  • Wirte the following code

MyWebDataContext context = new MyWebDataContext(“http://sp2013:2000&#8221;);

List<UsersItem> items=context.Users.ToList();

foreach (UsersItem item in items)






8 thoughts on “How to Read from SharePoint 2013 List in 6 Ways

  1. Pingback: Access SharePoint 2013 List date in six Process | Gupta's Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s