2016-04-05 37 views
0

我已經在SP 2010中創建了一個用戶組,並且我已經從列表設置中爲其添加了一個自定義列。 如何獲取Web部件中的自定義列值?
編輯:
我的自定義列是區。我想在可視化Web部件應用程序中返回該列值。
要返回用戶組我用這個代碼
List<SPUser> users = SPContext.Current.Web.SiteGroups["PDO Owners"].Users.ToList();
enter image description here如何從Sharepoint 2010用戶組獲取自定義列值

+0

我不明白你寫的是什麼意思,你已經爲用戶組添加了自定義列。你能提供你所做的和你想要達到的內容的截圖嗎? – Thriggle

回答

0

我假定你的意思是你創建的用戶配置文件的自定義屬性在我看來,你不能額外列添加到用戶組。您可以通過ProfileManager對象獲取值做這樣的事情:

//GET THE USER PROFILE MANAGER 
SPServiceContext sc = SPServiceContext.GetContext(site); 
UserProfileManager userProfileManager = new UserProfileManager(sc); 

//GET A PROFILE FOR A USER 
UserProfile profile = userProfileManager.GetUserProfile("i:0#.f|fbamembershipprovider|myfbauser"); 

string propertyvalue = profile["propertyinternalname"].Value.ToString(); 

根據字段的類型,你將不得不使用比的ToString別的東西(例如,用於管理元數據字段我認爲你應該使用TaxonomyFieldValue ,等等......)

+0

在Sharepoint 2010基礎我沒有Microsoft.Office.Server.UserProfiles.dll,我不能使用UserProfileManager –

相關問題