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 an event reciever for item adding.

I'm using:

dropdwnvalue = web.Lists[properties.ListId].Fields["Names"].InternalName;

string selectedValue = properties.AfterProperties[dropdwnvalue].ToString();

In selectedValue I'm able to get the index of the selected dropdownbox. Is there any way to get the value "Bob" instead of the index?

share|improve this question
up vote 2 down vote accepted

Check out this my blog post, it describes your situation.
Shortly, in before-receivers you always get a lookup id only (for lookup fields). If you want to get other item field values from lookup list, you must get item by this id and then get all required values.

share|improve this answer
Hi Kai, i tried from that example but, i m gettting the error that the item does not exits it must have been deleted by another user ..this is my code ----dropdwnvalue = web.Lists[properties.ListId].Fields["Names"].InternalName; var list = web.Lists["Demolist"]; if (int.TryParse(properties.AfterProperties[dropdwnvalue].ToString(), out id)) { var item = list.GetItemById(id); var categoryNo = item["Names"]; } I m getting the error at the line var item – spStacker Jan 17 '12 at 18:35
If Names is a lookup field, from what list it gets data? – Kai Jan 17 '12 at 18:53
Excellent Kai, i followed your example..and was able to get the name!..Thanks! – spStacker Jan 17 '12 at 19:03
Thanks for following up Kai! – Falak Mahmood Jan 17 '12 at 23:27

In general you can get it by using SPFieldLookupValue:

SPFieldLookupValue YourLookup = new (SPFieldLookupValue(Properties.AfterProperties.LisItem["Your lookup"] as string);

In your case the code would become:

dropdwnvalue = web.Lists[properties.ListId].Fields["Names"].InternalName;
String lookupFieldStringValue = Convert.ToString(properties.AfterProperties[dropdwnvalue]);
SPFieldLookupValue lookupFieldValue = new SPFieldLookupValue(lookupFieldStringValue);


int lookedUpItemID = lookupFieldValue.LookupId;

If you want to use both LookupId and LookupValue then you can use SPFieldLookupValue constructor with two parameters

Something like this:

share|improve this answer
Hi..when i debugged it is showing the lookupId=13..but the lookUpValue is "" empty.. – spStacker Jan 17 '12 at 16:36

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.