I have to get all the field (column) values in an array from a SharePoint list. Right now I am looping through all the items in the list and creating an array. But it is very inefficient if I have large number of items.

What would be the most efficient way to get all the field (column) values in an array from SharePoint List?

Update 1: The array values are further used in the code and are not displayed to end user.

  • Why u r not using DatTable? – Dikesh Gandhi Dec 15 '15 at 10:33
  • you looking for Jquery or CSOM/ SSOM ? – Gaurravs Dec 15 '15 at 10:34
  • @Gaurravs: SSOM. But if its possible in CSOM then it should be available in SSOM, right? – Naveen Dec 15 '15 at 10:37
  • @DikeshGandhi: SPList.GetDataTable() fetches me the data table. But then I cannot find any method in the DataTable Class that will return the column values in array. Or am I missing something here? Please elaborate what are you referring to. – Naveen Dec 15 '15 at 10:40
  • 1
    I guess use of generic list can also suffice your requirement – Gaurravs Dec 15 '15 at 11:24

Even I will suggest using DataTable than array

SPWeb oWebsite = SPContext.Current.Web;
SPList oList = oWebsite.Lists["List_Name"];
SPListItemCollection collListItems = oList.Items;

//DataTable oDataTable = collListItems.GetDataTable();

DataGrid1.DataSource = collListItems.GetDataTable();

you can either use grid or the commented line if want in datatable format for further functionality.


You can get list items collection in a generic list.

List<SPListItem> listItems = list.GetItems(query).Cast<SPListItem>().ToList();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.