Converting ListItemCollection to DataTable in Client side object model for SP Online

Dewadatta Avasare 0 Reputation points
2022-01-11T04:03:50.483+00:00

Is there any way to convert ListItemCollection to a datatable like we could do in Sharepoint server side code using
SPListItemCollection listcol= listname.GetItems(query);
DataTable datatableOne= new DataTable();
if (listcol!= null && listcol.Count > 0)
{
datatableOne= listcol.GetDataTable();
}
Is there any GetDataTable method for CSOM because I am unable to find one in documentation for SP Online.
Help would be much appreciated.

Microsoft 365 and Office SharePoint Development
Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2022-01-11T08:08:13.517+00:00

    Hi anonymous user ,
    There is no similar method in CSOM (C#). You have to build manually as like following code.
    163824-test.txt

    You can check the methods of ListItemCollection from the document


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.