SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using SPListItemCollection.GetDataTable to return the list search results. The GetDataTable doesn't contain all the columns that are mentioned in ViewFields, but I can see all those columns in SPListItemCollection.Xml property. Columns like AverageRating are missing. Is this a known issue?

I'm using datatable for doing some filtering and row operations on the returned result as it is easier to do with a datatable. Now I'm planning to create dataset from SPListItemCollection.Xml and return the datatable from there. Is there a better approach?


share|improve this question
plz post your code so i'll you provide perfect solution.. – Hitesh Chandegara Jan 19 '13 at 10:05
Code is like below..I have tested by writing the items.Xml and items.GetDataTable to an xml file. I can see that xml returned by GetDataTable doesn't contain the rating columns. SPListItemCollection items = list.GetItems(spQuery) return items.GetDataTable(); – Rajesh Jan 21 '13 at 9:03
I think also that the columns are not selected in the query. – Sascha Jan 6 '14 at 6:51

try this code... it'll work perfectly in my system.

  SPQuery query = new SPQuery();
  query.Query = string.Concat(
                            "<FieldRef Name='Status'/>",
                            "<Value Type='CHOICE'>Not Started</Value>",

  query.ViewFields = string.Concat(
                                  "<FieldRef Name='Title' />",
                                  "<FieldRef Name='StartDate' />",
                                  "<FieldRef Name='DueDate' />",
                                  "<FieldRef Name='Priority' />");

  query.ViewFieldsOnly = true; 

   SPListItemCollection oItem = splist.GetItems(query);
   DataTable objDatatable =   oItem.GetDataTable();

plz dont forget to apply query.ViewFieldsOnly = true;

Hope it helps.... :D

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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