SPList.Items foreach
This SPListItem Collection works directly against the underlying SharePoint List (SPList). Any updates made against List Items are updated on the server.
The below code shows enumerating through all List Items in a List.
using (SPWeb web = siteCollection.AllWebs["webname"])
{
SPListItemCollection items = web.Lists["Document Library"].Items;
foreach (SPListItem item in items)
{
Console.Write(item.Title);
}
}
---------------------------------------------------------------
using (SPWeb web = siteCollection.AllWebs["webname"])
{
SPList list = web.Lists["Document Library"];
DataTable table = list.GetItems(list.DefaultView).GetDataTable();
//TODO: enumerate DataTable
}
No comments:
Post a Comment