User Profile Data Web Part 读取属性字段
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Code
using (SPSite site = new SPSite("http://moss2010/"))
{
SPServiceContext context =
SPServiceContext.GetContext(site);
UserProfileManager m_mngr = new UserProfileManager(context);
//Get the properties
PropertyCollection props = m_mngr.Properties;
//Create a Dictionary to store property data.
Dictionary<string, string> UserProps = new Dictionary<string, string>();
foreach (Property prop in props)
{
UserProps.Add(prop.Name, prop.DisplayName);
}
//Bind the Dictionary to a GridView control.
GridView1.DataSource = UserProps;
GridView1.Columns[0].HeaderText = "Property Name";
GridView1.Columns[1].HeaderText = "Display Name";
GridView1.DataBind();
}