SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When you get an SPListItemCollection from a SPList.GetItems(SPQuery) request, and the items have SPFieldUser or SPFieldLookup fields, what is the sexy way to get typed values, not the item["Field"].ToString().Split('#')[1] way, please?

share|improve this question
up vote 23 down vote accepted
new SPFieldLookupValue(item["FieldName"] as String).LookupValue

you probably want to check if item["FieldName"] is not null or empty before doing this.

SPFieldUserValue works similarly, but you need to pass in an SPWeb into the constructor, which you can retrieve from your SPListItem using SPListItem.ParentList.ParentWeb

share|improve this answer
or .ToString() and yes check for null always – Anders Rask Feb 6 '10 at 10:29
Cool, at least this way we are protected from cases when hash/pound-sign(#) appears in the value. Thanks. – Alexey Krasheninnikov Feb 7 '10 at 20:19
cool - just googled for this question and stumbled upon my own answer :) – Jaap Vossers Aug 12 '10 at 11:43
I wrote an article about the whole get/set Lookup/User field method, which may be useful: – Stuart Pegg Jul 26 '12 at 11:38
@JaapVossers Future self thanks your past self. – David Sep 10 '15 at 12:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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