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?
+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
2009-08-12 09:52:21
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
2009-08-12 10:22:58
@Janis: you are right, thank you.
Tudor Olariu
2009-08-12 10:26:01
+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
2009-08-12 10:04:28