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

I have a list in SharePoint and it contains a lookup field. Now I want to insert an item to this list, but don't know how to work with the lookup field. I tried the following code but no item is added.

SPFieldLookupValue gov = new SPFieldLookupValue(gv.SelectedValue);
items["gov_name"] = gov.LookupValue;
share|improve this question
I thought my question is very easy but it's important for me :( – NOOR Apr 13 '13 at 20:04
I have edited your question (changed formatting). Please, approve this edit. It will help others in future. – MikhailSP Apr 13 '13 at 20:56
up vote 5 down vote accepted

Please, take a look at this question. So you can do something like this:

SPListItem lookedUpItem =  GetItemSomeHow();
newItem[lookupField] = new SPFieldLookupValue( lookedUpItem.ID, lookedUpItem.Title);

Hope it helps. If so, please, don't forget to press upvote and mark as answer. :)

share|improve this answer
Thanks for reply but What's getitemsomehow ?? – NOOR Apr 13 '13 at 20:33
this means that you need to obtain an SPListItem object you want to lookup to. For instance it could look like: SPListItem lookedUpItem=web.Lists["SomeList"].Items[1] for the item with ID=1 in the list "SomeList"; – MikhailSP Apr 13 '13 at 20:40
Thank you very much :) – NOOR Apr 13 '13 at 20:50

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.