//根据姓名获得当前网站下此人信息集合
SPFieldUserValue userValue = new SPFieldUserValue(SPContext.Current.Web,
getitme["ApplyName"].ToString());
//获得登录名
HiddenLoginName.Value = userValue.User.LoginName;
1、如果你设置栏不允许多重选择,也就是说只能选择一个人的话,获取栏的信息使用如下代码
SPFieldUserValue userValue = new SPFieldUserValue(web, item["WGMemberName"].ToString());
SPUser user= userValue.User.Name;
2、如果你设置栏可以多重选择,可以选择多个人或者组的话,获取栏信息如下代码
List<SPUser> Users = new List<SPUser>();
List<SPGroup> Groups = new List<SPGroup>();
using (SPSite Site = new SPSite("http://windbell"))
{
SPWeb Web = Site.RootWeb;
SPList List = Web.Lists["测试列表"];
SPItem Item = List.Items[0];
SPFieldUserValueCollection Values = (SPFieldUserValueCollection)Item["用户和用户组"];
foreach (SPFieldUserValue Value in Values)
{
if (User != null)
{
SPUser User = Value.User;
Users.Add(User);
}
else
{
SPGroup Group = Web.Groups.GetByID(Value.LookupId);
Groups.Add(Group);
Users.AddRange(Group.Users);
}
}
}
参考 http://www.cnblogs.com/virusswb/archive/2009/05/08/1452406.html