我有一个列表TheUser,其中一列user是用户类型的
string strWebUrl = SPContext.Current.Site.Url;
SPSite spSite = new SPSite(strWebUrl);
using (SPWeb spWeb = spSite.OpenWeb())
{
SPList spList= spWeb.Lists["TheUser"];
foreach (SPListItem spListItem in spList.Items)
{
string strUser = spListItem["User"].ToString();
int userId = int.Parse(strUser.Substring(0,strUser.IndexOf(";#")));
SPUser spUser = spWeb.AllUsers.GetByID(userId);
string loginName = spUser.LoginName; //用户名,不是显示名称
}
}