前面提到在sharepoint 2010 如何给讨论板(Discussion)话题添加回复(Reply)信息(Message)
以下是如何通过程序,获取这些所有回复信息。
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWeb web = SPContext.Current.Web;
SPList list = web.Lists["工作组讨论"];
//This Query gets all items of the topic with ID=1
string str = @"
<Where>
<Eq>
<FieldRef Name=""ParentFolderId"" />
<Value Type=""Integer"">1</Value>
</Eq>
</Where>
";
SPQuery query = new SPQuery();
//This line makes the query search ib all folders
query.ViewAttributes = "Scope=\"Recursive\"";
query.Query = str;
SPListItemCollection res = list.GetItems(query);
DataTable replyTable = res.GetDataTable();
DataList1.DataSource = replyTable;
DataList1.DataBind();
});