Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Get value from fields for list items using CSOM SP 2013 and C#

$
0
0

Hi.

I added a few columns (e.c. Column1, Column2 and ...) for the List in SP 2013. In the List there are a few records. How to get data entry and display them in a table. For example:

ClientContext ctx = new ClientContext(ServerUrl);
List lists = ctx.Web.Lists.GetByTitle(List_name);
ListItemCollection items = lists.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(lists);
ctx.Load(items);
ctx.ExecuteQuery();
DataTable table = new DataTable();
table.Columns.Add("ID");
table.Columns.Add("FieldValue1");
table.Columns.Add("FieldValue2");

foreach (ListItem item in items)
	table.Rows.Add(item.ID, item["Column1"], item["Column2"]);
Thanks!


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>