Salam All,

I have a SharePoint Task List with 2 custom fields
- Category :lookup from category list
- OriginalAssignedTo : User picker Allow multi, Users only

When i try to read these 2 fields it keep gives me the below error

"Value Does not fall within the expected Range"

iam getting items using SPQuery without determine the fields and check if the fields exist in the item then check if the field is not null

if(item["Category"] != null)
    item["Category"].ToString(); //----> here i get the error

I have tried the following as well
- read the FormattedValue and check if its null before i read it but the same
- read the field using : item.properties["Category"].ToString();

NOTE: I have another custom field and I am reading it just fine and the returned items have a value for these fields


2 Answers 2


you need to debug item["Category"].ToString(); and find out what is the value?

"Value Does not fall within the expected Range"

that denotes the casting is wrong or your looking at index 2 when there is only index o and 1.

so how are you getting the value?

string val = em["Category"].ToString();

but....what I belive is that your code is fine and there is somthing wrong with the lookup, the issue is resource throttling for lookup in your case! (as iv said index issue)

goto Central Admin, within Application Management click Manage Web Applications amd pick the web application in question. Now within the ribbon click on General Settings and pick Resource Throttling from hte dropdown menu. You should see List View Lookup Threshold and increase it's value to a reasonable number.

more detailed info can be found here on the subject:


the above is in 2010! sorry missed the title 2013! for your case you can use this in code!

SPList.EnableThrottling = false;

(splist is the list name that you have set!)


if this is not the case and it doesnt work out, is it happing for any user or selected users? this could be because of a known bug that has been fixed in one of the sp2013 updates! if you update sharepoint it would solve your issue if the first solution doesnt work!

look at august update that solves the bug!


  • in my case i have ncrease the lookup threshold for web application from CA thank you very much
    – Suhad
    Nov 5, 2013 at 11:55
  • no probs happy to help!
    – Ali Jafer
    Nov 5, 2013 at 13:06

Run code in SPSecurity.RunWithElevatedPrivileges

  • Could you please explain why the elevated privileges would solve the problem in the question?
    – Benny Skogberg
    Apr 11, 2015 at 4:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.