SPQuery item[column] does not fall within expected range RRS feed

  • Question

  • Heres my scenario.

    I will be querying from a custom list and will get all items with column value Name = specified SPUser, I will be updating the Accept column of this item to "Yes"

    So I already have the result and assigned it to an SPListItemCollection

    SPListItemCollection itemColl = list.GetItems(query);

    I will get the first SPListItem and will update this later  on

    SPListItem item = itemColl[0];

    now if I check the value of the Accept column

    if (Convert.ToString(item["Accept"]) == "No")

    //I get an error in item["Accept"] that says value does not fall within expected range

    so I am encountering an error here, I also used ViewFields in my SPQuery

    <FieldRef Name'Accept' />

    it also did not worked, I used ViewFieldsOnly = true, and it worked (i did not encountered the unexpected range error)

    but when I updated the item

    item.Update() or SystemUpdate()

    the unexpected range error was again encountered, upon googling this error, it says that the update cannot view all the fields

    so I have no choice but to remove the ViewFieldsOnly = true which lead me back to my error

    Any ideas on how to resolve this?

    ----------------------- Sharepoint Newbie

    Thursday, November 21, 2013 7:01 AM

All replies

  • Add the "Accept" Column in default view of your list

    with regards Ravichandra

    Thursday, November 21, 2013 7:34 AM
  • Thanks but its already in the default view (All Items)

    ----------------------- Sharepoint Newbie

    Thursday, November 21, 2013 7:59 AM