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?
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.
To get the URL of an SPListItem
, use Item.Url
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With