Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <param name="fieldName"></param>
        /// <param name="parentList"></param>
        /// <returns></returns>
        public static SPListItem GetFieldLookupAsSPListItem(this SPListItem item, string fieldName)
        {
            SPListItem lookupItem = null;

            try
            {
                SPFieldLookup      spfl  = item.ParentList.Fields.GetFieldByInternalName(fieldName) as SPFieldLookup;
                SPFieldLookupValue spflv = item.GetFieldAsSPLookup(spfl.Id);
                lookupItem = spflv.GetListItem(spfl);
            }
            catch (Exception x)
            {
                throw x;
            }

            return(lookupItem);
        }