Get field as SPUser from SPListItem -获取当中的用户
/// Gets the SPUser from field of Sharepoint list /// /// <param name="aItem">The item. /// <param name="aIntenalName">The internal field name /// private SPUser GetSPUser(SPListItem aItem, string aIntenalName) { SPFieldUser field = aItem.Fields.GetFieldByInternalName(aIntenalName) as SPFieldUser; if (field != null && aItem[aIntenalName] != null) { SPFieldUserValue fieldValue = field.GetFieldValue(aItem[aIntenalName].ToString()) as SPFieldUserValue; if (fieldValue != null) { return fieldValue.User; } } return null; }
Sharepoint list fields of type "User and Group" in object model as read as string, for example system field "Author", with this code you can getting this type of fields in the correct form.
作者:johnny
出处:http://www.cnblogs.com/sunjunlin
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。