Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to retrieve SharePoint Discussion Board replies and other information programmatically in C# code?

Posted on 2012-04-06
5
Medium Priority
?
3,900 Views
Last Modified: 2012-04-11
Hi, I have one discussion board name is PBG, user have posted some topic/subject and other users replied on those topic/subject.

Now I want to retrieve the information who replied (user login/display name) on which date topic wise.

I write below code to get all the topic/subject in that Discussion Board:
--------------------------------------------------------------------------------------------------------------------------------------
mySite = SPContext.Current.Site;
myWeb = mySite.OpenWeb();
SPList discussion_list = myWeb.Lists["PBG"];
DataTable dt = discussion_list.Folders.GetDataTable();
GridView1.DataSource = dt;
GridView1.DataBind();

Please share the code to retrieve information about users who replied and replied data with topic wise.
Thanks.
0
Comment
Question by:Minesh Shah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
Jamie McAllister MVP earned 2000 total points
ID: 37818540
0
 
LVL 10

Author Comment

by:Minesh Shah
ID: 37832086
Hi, thanks for sharing MSDN thread, I have written below code to get all topic/subject:
----------------------------------------------------------
mySite = SPContext.Current.Site;
myWeb = mySite.OpenWeb();
SPList discussion_list = myWeb.Lists["PBG"];
foreach (SPListItem folder in discussion_list.Folders)
{
Response.Write("Item Name: " + folder.Name + "<BR>");
Response.Write("Item ID: " + folder.ID + "<BR>");
Response.Write("Author: " + folder["Author"].ToString() + "<BR>");
Response.Write("Posted Date: " + folder["Created"].ToString() + "<BR>");
}
//----------------------------------------------------
But still I am not able to retrieve the replies information of each topic/subject means who replied and replied date because the code
 7) Loop through all discussion replies:
foreach (SPListItem listItem in myDiscussionList.Items)// not working giving error that “Unable to cast object of type 'Microsoft.SharePoint.SPList' to type 'Microsoft.SharePoint.SPListItem'.”
{
}
,
can you please share the code how to get replies information?
0
 
LVL 32

Expert Comment

by:Jamie McAllister MVP
ID: 37832126
The implication of the error message is that myDiscussionList.Items is returning a SPList rather than a SPListItemCollection. I'd find that very unlikely.

Can you step through the code and confirm this please?
0
 
LVL 32

Expert Comment

by:Jamie McAllister MVP
ID: 37832132
Alernatively, post your full code and I'll replicate it in my Sandbox later.
0
 
LVL 10

Author Closing Comment

by:Minesh Shah
ID: 37833982
thanks now it's working.
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question