sharepoint中使用PeopleEditor控件为列表项赋值示例
来源:互联网 发布:迟夙生的网络办公室 编辑:程序博客网 时间:2024/05/16 11:02
sharepoint中使用PeopleEditor控件示例
protected void Page_Load(object sender, EventArgs e){ try { SPWeb web = SPContext.Current.Web; // get a handle to the list we’ll be pulling values from SPList list = web.Lists["Demo"]; // using the querystring parameter containing the id, get the list item we’ll be dealing with SPListItem listItem = list.GetItemById(Convert.ToInt32(Request["id"])); // the managers column is of type Person or Group, so we can use a spfielduservaluecollection to store the values from it SPFieldUserValueCollection users = (SPFieldUserValueCollection)listItem["Managers"]; // our array will hold the entities we’ll use to eventually assign to the people editor control ArrayList entityArrayList = new ArrayList(); // loop through each use in the collection, set the key, add to the array for (int i = 0; i < users.Count; i++) { PickerEntity entity = new PickerEntity(); entity.Key = users[i].User.LoginName; entityArrayList.Add(entity); } Managers.UpdateEntities(entityArrayList); } catch (Exception ex) { Response.Write(ex.ToString()); } }
-----------------------------------
protected void btnSubmit_Click(object sender, EventArgs e){ // create a web object with context for the current site SPWeb web = SPContext.Current.Web; // get the entries that were entered into the people editor and store them in a string string managers = peManagers.CommaSeparatedAccounts; // commaseparatedaccounts returns entries that are comma separated. we want to split those up char[] splitter = { ',' }; string[] splitPPData = managers.Split(splitter); // this collection will store the user values from the people editor which we'll eventually use // to populate the field in the list SPFieldUserValueCollection values = new SPFieldUserValueCollection(); // for each item in our array, create a new sp user object given the loginname and add to our collection for (int i = 0; i < splitPPData.Length; i++) { string loginName = splitPPData[i]; if (!string.IsNullOrEmpty(loginName)) { SPUser user = web.SiteUsers[loginName]; // you could also use SPUser user = web.EnsureUser(loginName); SPFieldUserValue fuv = new SPFieldUserValue(web, user.ID, user.LoginName); values.Add(fuv); } } // set the Person or Group column SPListItemCollection listItems = web.Lists["Demo"].Items; SPListItem manager = listItems.Add(); manager["Managers"] = values; manager.Update();}
http://blog.sina.com.cn/s/blog_53864cba0100jjhn.html
- sharepoint中使用PeopleEditor控件为列表项赋值示例
- SharePoint PeopleEditor 控件的使用
- SharePoint PeopleEditor 控件的使用
- SharePoint PeopleEditor 控件的使用
- SharePoint PeopleEditor 控件的使用
- sharepoint 2010 从PeopleEditor控件中取出多用户,并返回SPFieldUserValueCollection
- PeopleEditor赋值操作(原创)
- sharepoint中列表的使用
- Sharepoint中为列表添加自定义的菜单项
- 自动化测试中FindWindow与FindWindowEx的使用为输入框赋值示例
- 自动化测试中FindWindow与FindWindowEx的使用为输入框赋值示例
- 为什么在SharePoint中使用FormDigest控件
- sharepoint 查阅项 赋值
- Sharepoint 列表字段赋值取值方法
- mfc中使用列表控件
- 使用xml为列表控件绑定数据
- 在SSIS中使用SharePoint列表作为源和目标
- 在SSIS中使用SharePoint列表作为源和目标
- 河软CSDN高校俱乐部落户新浪微博啦!!
- truncate操作与delete操作对比
- 关于CSS+DIV 开发 与各浏览器的兼容性问题及解决方法
- 关于CSS+DIV,浏览器兼容问题的一些心得
- java设计模式---Abstract Facotry Pattern---抽象工厂模式
- sharepoint中使用PeopleEditor控件为列表项赋值示例
- 学习心得
- 《stlport》源码解析-目录篇 @原创@
- html
- 我也来当刁民
- 利用php来嗅探劫持服务器数据
- Oracle 高水位线的一点研究
- Git分支
- kbuild系统-编译到内核和编译成模块的区别