Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SharePoint List Error: "Value does not fall within the expected range"

Hi I am developing using the SharePoint namespace and I ran into the following error when I try to retrieve a URL column from one of my lsits.

 "Value does not fall within the expected range"

All I am doing is:

item["URL"]

Can someone tell me what I can do about this?

like image 827
Oliver S Avatar asked Mar 02 '09 18:03

Oliver S


2 Answers

The error definitely means that the field can't be found.

Debug the process and look at the ListItem.Fields.SchemaXML property to find its internal name, it may be saved internally as something other than URL. You can also use the following method to get a list item value.

SPField l_field = l_item.Fields.GetField("URL");
string l_fieldValue = l_item[l_field.Id].ToString();

The GetField method looks for a field by both DisplayName & InternalName.

like image 166
Jason Avatar answered Oct 12 '22 10:10

Jason


To get the URL of an SPListItem, use Item.Url.

like image 22
Andy Mikula Avatar answered Oct 12 '22 11:10

Andy Mikula