I have created a visual WebPart contains a people Editor control to pick the Manager Name(infact only one name). The control is working fine but i would like to store the particular value to a variable using code during the button click . how can i achive this ? any help?
Asked
Active
Viewed 2.0k times
2 Answers
5
I got the answer.Thanks for the idea. Below is the code which works fine for me.
SPWeb mySite = SPContext.Current.Web;
SPListItemCollection listItems = mySite.Lists["myList"].Items;
SPListItem item = listItems.Add();
string[] UsersSeperated = pplEditor.CommaSeparatedAccounts.Split(',');
SPFieldUserValueCollection UserCollection = new SPFieldUserValueCollection();
foreach (string UserSeperated in UsersSeperated)
{
mySite.EnsureUser(UserSeperated);
SPUser User = mySite.SiteUsers[UserSeperated];
SPFieldUserValue UserName = new SPFieldUserValue(mySite, User.ID, User.LoginName);
UserCollection.Add(UserName);
}
item["people"] = UserCollection;
item.Update();

Jignesh Rajput
- 3,538
- 30
- 50

missReclusive
- 105
- 1
- 4
- 20