1

I am attempting to grab the text value of a lookup dropdown after an Item is Added.

The way I'm currently doing this, gives me the string 23#ADMIN, which is the combined ID and text. I could go the dirty route and parse this text, but I figure there must be a way to just grab ONLY the text portion without manipulation.

I'm currently doing this like so:

SPListItem requestItem = properties.ListItem;               
var tradeClass = requestItem[tradeClassCol].ToString();

How can I accomplish grabbing just the selected item's text? And if so, is there a simpler way to just grab the ID as well?

EDIT:

I have also attempted this solution, but have had no luck. I get the error "Column XXX does not exist..." I think this may have something to do with it being a Lookup column?

Thanks

2 Answers 2

2

You can use:

string value = (new SPFieldLookupValue(item["FieldName"] as String)).LookupValue

0
0

I used it like this

string value = (new SPFieldLookupValue(properties.ListItem["FieldName"].ToString())).LookupValue;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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