Search code examples
c#sharepointado.netmosswindows-sharepoint-services

Sharepoint List to ADO.Net data table


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?


Solution

  • 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();