Tuesday, October 1, 2013

How to print Sharepoint list column name with values in console window in Horizontal way.

Hi,


Your code should look like this:#



foreach (SPList list in web.Lists)
{
if (list.Fields.ContainsField("AssignTo"))
{
Console.WriteLine(String.Format("Item Name: {0}", listItem.Name));
for (int i = 0; i < listItem.Fields.Count; i++)
{
if (listItem.Fields[i].CanBeDeleted)
Console.Write(String.Format("{0}\t", listItem.Fields[i].StaticName));
}
Console.WriteLine();

//Console.WriteLine(list);

foreach (SPListItem listItem in list.Items)
{
try
{
for (int i = 0; i < listItem.Fields.Count; i++)
{
if (listItem.Fields[i].CanBeDeleted)
Console.Write(String.Format("{0}\t", listItem[i])));
}
Console.WriteLine();
}
catch (Exception ex)
{

}
}
}
}

Cheers,


Dan.




You can find my blog here: http://developertrack.blogspot.com


No comments:

Post a Comment