我可能会遗漏一些东西。我在一个部分中有一个多选列表框。见附图。当我右键单击 grpApplications 并复制 XPath 时,它给了我 /my:myFields/my:grpAccessOfficeEquipment/my:grpApplications 当我右键单击 fldApplicatins 上的 XPath 时,它给了我 /my:myFields/my:grpAccessOfficeEquipment/my:grpApplications/我的:fldApplications
在代码(下面发布的代码)中,我引用了 /my:myFields/my:grpAccessOfficeEquipment/my:grpApplications/my:fldApplications 并且没有任何价值。但我使用了 /my:myFields/my:grpAccessOfficeEquipment/my:grpApplications 我得到了列表框中所选项目的值。
但我仍然在字符串 appName 行上收到错误 NullReferenceException“对象引用未设置为对象的实例”。AppID 看起来像这样 "\n\t\t\t262265264143\n\t\t" 而不是调试中的整数。但是当我点击双筒望远镜时显示 262265264143 但在此之前和之后都有空格/行
XPathNavigator MainDS = MainDataSource.CreateNavigator();
XPathNodeIterator iterApp = MainDS.Select("/my:myFields/my:grpAccessOfficeEquipment/my:grpApplications", NamespaceManager);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
while (iterApp.MoveNext())
{
string AppID = iterApp.Current.Value;
//int lookupID = Convert.ToInt16(value);
XPathNavigator secAPPDS = DataSources["SupportEscalationList"].CreateNavigator();
string appName = secAPPDS.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[@ID = '" + AppID + "']/@ApplicationProcess", NamespaceManager).Value;
sb.Append(appName);
item["ApplicationProcess"] = sb.ToString(); // because applicationprocess column in target sp list is single text type column
}