Get items from SharePoint Task List

I have created a Task List in SharePoint Server 2013. I need to retrieve items from this task List. I am using the following code.

SPSite site = new SPSite(".......");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Tasklist"];
foreach (String fieldName in list.Views["All Tasks"].ViewFields)
{
 Console.WriteLine(fieldName);
}

I notice that the above method does not retrieve all items. Also I have tried reading the items using list.Fields which will pull all items (hidden,unwanted columns). Can anyone suggest me any method to get the items from task list?

Answers


As per your code "All Tasks" is your view and you are retriving the fields which you have set as checked in your View. So Check your "All Tasks" view in the list and Modify the View with the correct Fields which you want to retrieve.

If you want to rerieve all the items using this method Check the Fields as marked in the modify View Section of the list.


Need Your Help

ERROR 1062 (23000): Duplicate entry '2147483647' for key 'PRIMARY'

mysql sql

First off all, i've seen many others post like this, however the answer wasn't working on my particular case.

How to add System.Web.Mvc version 5 to the project references

asp.net-mvc visual-studio-2013 reference asp.net-mvc-5 nuget-package

When I want to add System.Web.Mvc by right clicking the project and Add>Reference option, there is only version 3.0.0.0 and 4.0.0.0. However, I created the project as MVC 5. On the other hand, tryi...