将SharePoint 2010查阅项的值读取到一个listbox中
这是一个例子,通过SharePoint 2010客户端对象模型从一个SharePoint 2010查阅项字段中读取值,来写入到一个asp.net listbox控件中。
ClientContext clientContext = new ClientContext(“https://mySPsite”); clientContext.AuthenticationMode = ClientAuthenticationMode.Default; List list = clientContext.Web.Lists.GetByTitle(“MYList”); CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = “<View/>”; ListItemCollection listItems = list.GetItems(camlQuery); clientContext.Load(listItems); clientContext.ExecuteQuery(); foreach (ListItem listItem in listItems) { // Get value SP.FieldLookupValue _value = listItem.FieldValues["MyLookupFieldID"] as SP.FieldLookupValue; var mylookupvalue= _value.LookupValue; listBoxControl1.Items.Add(mylookupvalue); }
参考资料