Consider the following code:-

SPListItemCollection collListItems = emp_info.GetItems(query);
dt = collListItems.GetDataTable();

Now i want to convert the dt object back to SPListItemCollection object

Is this possible in one of the following ways


SPListItemCollection collec1= dt as SPListItemCollection;


  SPListItemCollection collec1= (SPListItemCollection)dt;

If not is there any other way where i can convert DataTable object back to a SPListItemCollection object.

Anyone with any ideas, Thanks....

2 Answers 2


You have to iterate through DataTable and fill into SPListitemCollection object.

Also check following link for the code details:



The above mentioned techniques would have only work if DataTable would have been derived from SPListItemCollection.

Since its not the case, so you will have to iterate over the rows in DataTable and will have to create list items for each row and associate it with appropriate properties.

  • But the datatable is derived from SPListItemCollection Commented May 15, 2014 at 6:35
  • Nope dude check DataTable class [msdn.microsoft.com/en-IN/library/system.data.datatable.aspx]. When you execute method collListItems.GetDataTable(); it internally creates a new DataTable object and creates DataRow for all your listItems and add those rows into the DataTable. And this DataTable is returned as an object. Commented May 15, 2014 at 6:45
  • you can also check the details of SPListItemCollection.GetDataTable() (msdn.microsoft.com/en-us/library/…). Its basically a converter. Commented May 15, 2014 at 6:51
  • Hit the response as answer if that suffices you as answer. Commented May 15, 2014 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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