查询Sharepoint-值不在预期范围内

查询Sharepoint-值不在预期范围内,sharepoint,caml,argumentexception,Sharepoint,Caml,Argumentexception,我正在尝试检索listitem的值,但不断获取ArgumentException-值不在预期范围内 我的代码如下: if (resultList.Count > 0) { SPListItem result = resultList[0]; if (result[Column] != null) { return result[Co

我正在尝试检索listitem的值,但不断获取ArgumentException-值不在预期范围内

我的代码如下:

if (resultList.Count > 0)
            {
                SPListItem result = resultList[0];

                if (result[Column] != null)
                {
                   return result[Column].ToString();
                }
            }
在即时窗口中,我可以验证列是否存在,并且可以在对象树结构中找到值

result.Fields.GetField(Column).Id 
返回Guid,但使用它检索字段值会导致另一个ArgumentException:

result[result.Fields.GetField(Column).Id]

您需要使用字段的InternalName从SPListItem获取其值

result[result.Fields.GetField(Column).InternalName]

您需要使用字段的InternalName从SPListItem获取其值

result[result.Fields.GetField(Column).InternalName]

如果从视图(list.GetItems(view))或使用ViewFields属性集的查询获取列表项集合,则可能会发生这种情况,在这种情况下,仅返回ViewFields中包含的字段。

如果从视图(list.GetItems(view))或使用ViewFields属性集的查询获取列表项集合,则可能会发生这种情况,在这种情况下,只返回ViewFields中包含的字段。

我找到了异常的原因:我使用了List.GetItems(字符串)而不是SPQuery重载我找到了异常的原因:我使用了List.GetItems(字符串)而不是SPQuery重载