我是sharepoint的新手,我正在尝试编写一个Web服务来将我们的sharepoint库存数据作为xml返回.除了其中一个列表包含查找字段并且生成的xml包含"Microsoft.SharePoint.Client.FieldLookupValue"而不是查找字段的预期字符串值之外,它的工作正常.
这是我用来生成xml的代码:
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"]);
}
Run Code Online (Sandbox Code Playgroud)
item ["Location"]是查找字段,它有一个类型的值FieldLookupValue,如何将查找值作为字符串?
Meh*_*din 15
好的,使用以下代码语法成功获取查找字段的值:
string Location = "";
if (item["Location0"] != null)
{
var fl = (SPFieldLookupValue)item["Location0"];
Location = fl.LookupValue;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
41095 次 |
| 最近记录: |