23 Ekim 2013 Çarşamba

SharePoint Webpart-Populate Users with Repeater



List<UserInfo> userList = new List<UserInfo>();
 
        protected void Page_Load(object sender, EventArgs e)
        {
            SPWeb web = SPContext.Current.Web;
            SPUserCollection U1 = web.Users; //include allusers and SiteUsers 
            SPUserCollection U2 = web.AllUsers;
            SPUserCollection U3 = web.SiteUsers;
            
            foreach (SPUser user in U2)
            {
                UserInfo cs = new UserInfo();
                cs.name = user.Name;
                cs.mail = user.Email;
 
                userList.Add(cs);
            }
 
            rptUsers.DataSource = userList;
            rptUsers.DataBind();
            
 
        }
    }
 
    class UserInfo
    {
        public string name { getset; }
        public string mail { getset; }
 
    }

Kolay Gelsin...