Я получаю несколько строк из списка Sharepoint.Количество элементов возвращается 2, но когда я пытаюсь получить элементы в DataTable с помощью метода GetDataTable, он возвращает ноль.
Вот мой код:
public DataTable GetInbox()
{
using (SPSite site = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists.TryGetList("PromotionRecommendationList");
var q = new SPQuery()
{ //recommend by current user and status is change request means request is visible to requestor in editable mode
Query = @"<Where> <And>
<Eq>
<FieldRef Name='RecommendBy_EmpCode' />
<Value Type='Text'>"+obj_vemployee.GetEmployeeCode(GetLoggingName(CurrentUser.LoginName))+"</Value></Eq><Eq><FieldRef Name='Status' /><Value Type='Text'>"+Status.ChangeRquest+ "</Value></Eq></And><Or><Eq><FieldRef Name='assign_to_EmpCode' /><Value Type='Text'>" + obj_vemployee.GetEmployeeCode(GetLoggingName(CurrentUser.LoginName)) + "</Value></Eq></Or></Where>"
};
q.ViewFields = @"
<FieldRef Name='Request_No' />
<FieldRef Name='RecommendBy_EmpCode' />
<FieldRef Name='RecommendTo_EmpCode' />
<FieldRef Name='STATUS' />
<FieldRef Name='RequestStatus' />
";
var r = list.GetItems(q);
lblTEst.Text = list.Items.Count.ToString();//this is returning 2
DataTable dtResults = r.GetDataTable();//returning null
return dtResults;
}
}
return null;
}