How to retrieve and set lookup value in SharePoint2010
In this post, I’d like to show you how to retrieve and set the lookup value. In SharePoint2010, the lookup value you retrieve is in the format as {LookupItemID};#{LookupFieldValue}
You can download a solution here, after you deploy the SharePoint solution then you can run the console application as follows and the result is as follow:
Now, let’s look at the code to retrieve the lookup value, you can see I first retrieve the value by using the normal way of retrieving the lookup value and the value you got is 1;#Accounting. To parse the value, you need to create a SPFieldLookupValue type and you can grab the id using LookupId property and grab the value using LookupValue property.
To Set the LookupValue , you can create a SPFieldLookupValue type and assign to the lookup item or just assign the ID directly to the lookup item.
-
January 3, 2012 at 8:16 am | #1SharePoint 2010: Recopilatorio de enlaces interesantes (XXVII)! – Blog del CIIN
-
January 3, 2012 at 8:18 am | #2SharePoint 2010: Recopilatorio de enlaces interesantes (XXVII)! « Pasión por la tecnología…







