2012-07-04 76 views
3

我是比較新的SharePoint和嘗試寫一個Web服務來回報廣大的SharePoint庫存數據爲XML這是確定到現在爲止,但這些列表中的一個包括一個查找字段,並在創建的XML而不是返回值它返回下面的類。獲取查找字段值在SharePoint 2010列表項使用C#

Microsoft.SharePoint.Client.FieldLookupValue 

下面還包括我用來創建XML

//id == "pcat:401824" && category == Altyapı.Kamera sistemleri 
resultList = remoteWeb.Lists.GetByTitle("Cam Devices"); 
context.Load(resultList); 
context.ExecuteQuery(); 
//Now its time to reach list's items 
items = resultList.GetItems(new CamlQuery()); 
context.Load(items); 
context.ExecuteQuery(); 
foreach (ListItem item in items) 
{ 
    rootNode.AppendChild(doc.CreateElement("ID")).InnerText = "pcat:401824"; 
    rootNode.AppendChild(doc.CreateElement("Category")).InnerText = "Cam Devices"; 
    rootNode.AppendChild(doc.CreateElement("Kimlik")).InnerText = Convert.ToString(item["ID"]); 
    rootNode.AppendChild(doc.CreateElement("Isim")).InnerText = Convert.ToString(item["Location0"]) + " >> " + Convert.ToString(item["Brand"]) + " >> " + Convert.ToString(item["ID"]); 
} 

上面的代碼項目[「位置」]是一個查找字段,是一個問題的代碼,所以只是搜索互聯網並有很多關於情況的文章,但無法弄清楚他們有一個名爲FieldLookupValue的類,但是如何使用它來獲取字段的查找值?

一切都有助於將理解和我的皮江英語

+0

這也很有幫助[獲取和設置SharePoint查找字段值使用SSOM C#](https://social.technet.microsoft.com/wiki/contents/articles/40271.get-and-set-a-sharepoint-lookup-field-values-using-ssom-c.aspx ) –

回答

15

好難過,

順利拿到通過使用下面的代碼語法查找字段的值,它可以幫助脂肪酶從谷歌

string Location = "";

if (item["Location0"] != null) 
{ 
    var fl = (SPFieldLookupValue)item["Location0"]; 
    Location = fl.LookupValue; 

} 

未來

感謝大家閱讀我的問題

+0

演員做了這個工作,非常感謝! – Lennon

相關問題