Your strategic advantage starts here

Parsing a SharePoint Lookup Field using SPFieldLookupValue

Parsing a SharePoint Lookup Field using SPFieldLookupValue

This is a quick example of parsing a SharePoint Lookup field using SPFieldLookupValue.  As we know, SharePoint lookup fields are usually formed as such:

[Lookup ID];#[Lookup Value]

Rather than manually parsing this result (by perhaps splitting the returned string by ‘;#’) we can simply obtain these values using the SPFieldLookupValue:

SPFieldLookupValue splv = new SPFieldLookupValue(oListItem["User_x0020_Email"].ToString());

lookupIdStr = splv.LookupId.ToString();
lookupValueStr = splv.LookupValue.ToString();

 

 

Related Posts
Leave a Reply
Give us a call

Available from 9am to 8pm, Monday to Friday.

Send us a message

Send your message any time you want.

Our usual reply time: 1 Business day
Give us a call

Available from 9am to 8pm, Monday to Friday.

Send us a message

Send your message any time you want.

Our usual reply time: 1 Business day