2010-01-31 67 views
1

內工作,這是一個在C控制檯應用程序代碼尖銳的SharePoint服務器上執行CAML查詢2007修改控制檯應用程序C鋒利代碼從SharePoint

using System; 
using System.Collections.Generic; 
using System.Text; 
using Microsoft.SharePoint; 
namespace SharePointUtils 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      string siteUrl = args[0]; 
      string listName = args[1]; 
      string viewName = args[2]; 
      SPSite site = new SPSite(siteUrl); 
      SPWeb web = site.OpenWeb(); 
      SPList employeesList = web.Lists[listName]; 
      SPQuery query = new SPQuery(employeesList.Views[viewName]); 
      System.Diagnostics.Debug.WriteLine(query.ViewXml); 
      Console.WriteLine(query.ViewXml); 
      Console.ReadLine(); 
     } 
    } 
} 

這將如何更改代碼,如果相同的代碼不作爲控制檯應用程序執行,但是代碼是使用按鈕單擊操作/某些類似的用戶在SharePoint列表視圖中的交互來執行的。並且結果也顯示在sharepoint內,例如在aspx頁面中。

如果可能的話,請給aspx頁面創建一些提示。

真的,任何級別的幫助都會受到真誠的讚賞。

回答

1

第一步可能是將結果作爲Datatable檢索並將其綁定到aspx DataGrid/DataView控件。

要將結果作爲DataTable獲得,您可以使用SPListItemCollection的GetDataTable方法。

+0

非常感謝親愛的 – silverkid 2010-01-31 18:42:55