Tuesday 13 May 2014

Get SPList Data

public DataTable getList()
{
SPSite siteCollection = null;
SPWeb topLevelSite = null;
SPListItemCollection myitems = null;
try
{
siteCollection = new SPSite("");
topLevelSite = siteCollection.AllWebs[""];
SPList list = topLevelSite.Lists[""];
myitems = list.Items;
//Get the Datatable for ALL the list items
dtNewItems = myitems.GetDataTable();
return dtNewItems;
}
catch (Exception ex)
{
throw ex;
}
}