我有一個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