2014-10-06 72 views
0

**我有一個SharePoint列表稱爲「資源」,並有各個領域如下圖所示,同樣的回報作爲數據表:檢索SharePoint列表DataTable中與條件

ID Title  Role  LoginName Enable[Yes/No] 
1 Pranav Developer BW\PPB  Yes 
2 Rohit  Tester  BW\RW  No 
3 Sarang Account  BW\SJ  No 
4 Amit  Soft.Eng  BW\AI  Yes 
4 Kunal  Soft.Eng  BW\KT  Yes 

**我的代碼:

public static DataTable GetListData() 
     { 
      DataTable returnTable = null; 

      SPSite thisSite = null; 
      SPWeb thisWeb = null; 
      SPList thisList = null; 

      try 
       { 
      thisSite = new SPSite(siteLink); 
      thisWeb = thisSite.OpenWeb(); 
      thisList = thisWeb.Lists["Resources"]; 
      if (thisList.Items.Count > 0) 
       { 
      filterQuery = new SPQuery(); 
      filterQuery.ViewFields = PopulateFieldsParameter("Title,Role,AddtionalRoles,Designation,LoginName,ClientBillable,NonBillable, EnableChatting,LoggedIn,EnableTimesheet,DesignationTitle,pmPODEnable"); 
      returnTable = thisList.GetItems(filterQuery).GetDataTable(); 
       } 
     returnTable = thisList.Items.GetDataTable(); 
     } 
     return returnTable; 
     } 

有了這個上面的代碼,我能夠檢索整個列表數據,但我想要獲取啓用爲是的表(行)。

實際輸出

ID Title  Role  LoginName Enable[Yes/No] 
    1 Pranav Developer BW\PPB  Yes 
    2 Rohit  Tester  BW\RW  No 
    3 Sarang Account  BW\SJ  No 
    4 Amit  Soft.Eng  BW\AI  Yes 
    5 Kunal  Soft.Eng  BW\KT  Yes 

期望輸出 -condition =啓用==是

ID Title  Role  LoginName Enable[Yes/No] 

1 Pranav Developer BW\PPB  Yes 
4 Amit  Soft.Eng  BW\AI  Yes 
5 Kunal  Soft.Eng  BW\KT  Yes 

幫助.. !!

在此先感謝。

回答