Cómo obtener un SPFieldLookupValue de un SPListItem?
-
16-10-2019 - |
Pregunta
Al obtener una SPListItemCollection
de una petición SPList.GetItems(SPQuery)
, y los artículos tienen campos SPFieldUser
o SPFieldLookup
, ¿cuál es la forma atractiva para obtener valores escritos, no de la manera item["Field"].ToString().Split('#')[1]
, por favor?
Solución
new SPFieldLookupValue(item["FieldName"] as String).LookupValue
you probably want to check if item["FieldName"]
is not null or empty before doing this.
SPFieldUserValue
works similarly, but you need to pass in an SPWeb
into the constructor, which you can retrieve from your SPListItem
using SPListItem.ParentList.ParentWeb
Licenciado bajo: CC-BY-SA con atribución
No afiliado a sharepoint.stackexchange