我有一个SPListItem
,我有一个列名称的数组。 当我尝试使用以下代码来访问SPListItem
值:SPList项目获取值 - ArgumentException
for(int i=0;i<arrColName.length;i++)
{
string tempValue = item[arrColName[i]].ToString();
// Works fine in case the the specific column in the list item is not null
// Argument exception - Values does not fall witing expected range
// exception in case the value //is null
}
为什么需要我很长时间才能找到答案?为什么SharePoint不会给我一个更好的错误信息,比如,“嘿,你知道那个你想要获得的价值的领域?好吧,我在你正在访问的SPListItem中看到它,但它并不是真的在那里,因为你的SPQuery没有说要检索它,请继续并将该字段添加到您的SPQuery中,这样您就会变得非常好。“ – 2014-07-03 18:19:58