Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, December 12, 2008 6:49 AM
Hi
I get the error message above on the following piece of code:
SPView _view = Web.Lists["Client Contact"].Views["All Items"];
SPListItemCollection listItems = Web.Lists["Companies"].GetItems(_view);
string CompanyChoice = default(string);
string comp = "Company";
IEnumerable<string> FilteredLists = listItems.OfType<string>().Where(listItems[comp].ToString().Equals(CompanyChoice));
I get the error on the last line, I'm not enitrely sure why?
Can anyone see where I am going wrong?
many thanks
All replies (1)
Saturday, December 13, 2008 2:37 PM âś…Answered
If you new to linq you should watch the videos at http://www.asp.net/learn/linq-videos/.
You have to pass a function that takes a string and returns true or false in your case. Something like this:
listItems.OfType<string>().Where(li => li.ToString().Equals(CompanyChoice));