Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to show a particular thread that resides in a discussion board. I am currently trying to use SPViews.

The following is my code

            SPView threadedView = discussionBoard.Views["Threaded"];
        threadedView.Title = "Comments WebPart";

        //threadedView.Query = query.ToString();
        threadedView.RenderAsHtml();

however this view is giving me all the discussion threads in the discussion board not a single thread which is needed. tried also to set a query for the view but was useless. can anyone help pls.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

You should treat Discussions as Folders and Threads as plain items. Basically the content types are Discussion (which inherits from Folder) and Message. Afterwards the best is to use SPQuery to retrieve the Items or simple GetItemById on the list to retrieve your item.

The Message has a field as follows <Field ID="{7662cd2c-f069-4dba-9e35-082cf976e170}" Type="Note" RichText="TRUE" RichTextMode="FullHtml" IsolateStyles="TRUE" NumLines="15" Name="Body" DisplayName="$Resources:core,camlid2;" Sortable="FALSE" AllowDeletion="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Body"> </Field> which returns the full content of it. Just retrieve it.

Hope it helps, C:\Marius

share|improve this answer
add comment

If this is in a webpart or usercontrol and you want to show the view in an aspx page, then you just need this code and then pass in the url parameter ?RootFolder=... and this will give you all the messages under this discussion.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.