2

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.

2 Answers 2

2

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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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