Sharepoint 2013 Community site: Get values from discussion board

1.2k Views Asked by At

I have to get values programmatically from the discussions list. When I tried this code it is giving the values of replies.

SPList oSpListPost = oSPWeb.Lists["Discussions List"];
SPListItemCollection oSpListItemClnPost = oSpListPost.Items;

foreach (SPListItem post in oSpListItemClnPost)
{
       SPField field = post.Fields.GetField("Body");
}
1

There are 1 best solutions below

0
On

The "parent" discussion is a folder with attached metadata, not a list item. You will probably want to get the associated folders in the list instead of the individual list items.