0

Hi there

Below source printing only the List Items that are on the first page of the SPList. Not printing the ListItems data in other pages i.e., Page 2, PageĀ 3 etc.

Also it is required to print SPLookupFieldValue, rather than suggesting some links any modifications to the below source that can meet the requirement is greatly appereciated.

static void Main(string[] args)
{
using (SPSite site = new SPSite(“http://intranet.contoso.com”))
{
using (SPWeb web = site.OpenWeb())
{
// Get data from a list.
SPList list = web.Lists[“Products”];
SPView view = list.DefaultView;

SPListItemCollection items = list.GetItems(view);
// Get a collection of view field names.
StringCollection viewFields = view.ViewFields.ToStringCollection();
// Print data for each item in the view.
foreach (SPListItem item in items)
{
// Print the value of each view field.
foreach (string fieldName in viewFields)
{
Console.WriteLine(“{0} = {1}”, fieldName, item[fieldName]);
}
Console.WriteLine();
}
}
}
Console.ReadLine();
}

Country Column is Lookup, so the data is printed with ID and value. Needs to print only the value.

Product = Television
CountryĀ  = 2;#uk

Product = Car
Country = 1;#india

 

(Visited 56 times, 1 visits today)
Add a Comment