views:

599

answers:

3

Is it possible to convert a share point list (getting it via the web service or object model) and transform it into a ADO.NET data table?

A: 

For Web Service Try out this Link, but it is straight Forward in the Object Model.

Kusek
+1  A: 

Get the list items through a SPQuery,

SPWeb web = SPContext.Current.Web;
SPSiteDataQuery query=new SPQuery();

//write your own query
// ...

//execute the query 
DataTable tbl = web.GetSiteData(query);

Now you have a ADO.NET DataTable to work on.

Tudor Olariu
For GetSiteData you must pass SPSiteDataQuery object. Fix it.Moreover, with SPSiteDataQuery it is possible to get list data from multiple lists.http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx
Janis Veinbergs
@Janis: you are right, thank you.
Tudor Olariu
+2  A: 

Or using the GetDataTable method in the OM:

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

DataGrid1.DataSource = collListItems.GetDataTable();
DataGrid1.DataBind();
ArjanP