1

I have a SPListItem, with different fields (string, lookup, etc), that I have to iterate them and do different actions depending of the type.

How can I detect if value is type String or type Lookup?

  value = spListItem["nameField"];  // is string or lookup?

2 Answers 2

1

You can simply use the C# is operation. Ie.

if (value is SPFieldLookupValue) {}
0

try this

string tipoCampo = itemCollection.Fields[ColumnsAssignation.ComboText].TypeAsString;
if (tipoCampo == "Lookup") {}

Your Answer

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

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