[英]Retrieve all items from a SharePoint Field Choice Column with using ObjectModel
I know a similar question has already been asked, but that retrieves all the items for Choice field using Sharepoint Object Model. 我知道已经问过类似的问题 ,但是使用Sharepoint Object Model检索Choice字段的所有项目。 I dont have object model available to me.
我没有可用的对象模型。 I want to do this using CAML or something.
我想使用CAML或其他方式执行此操作。 I couldnt figure out a CAML query to get all the items for a choice field.
我无法找出一个CAML查询来获取选择字段的所有项目。
Any pointers in the right direction will be really appreciated. 正确方向的任何指针将不胜感激。
Regards. 问候。
Can you use web service calls? 您可以使用网络服务电话吗? This thread explains reading multi-choice choices from a web service: http://social.msdn.microsoft.com/Forums/en/sharepointdevelopment/thread/04a00936-7102-4ddc-aa7d-0be7e14e7692 This follow-up post might be useful, too: http://mysharepointwork.blogspot.com/2009/10/sharepoint-web-services-get-choice.html
此线程说明了从Web服务中读取多项选择的方法: http : //social.msdn.microsoft.com/Forums/en/sharepointdevelopment/thread/04a00936-7102-4ddc-aa7d-0be7e14e7692此后续帖子可能有用,也: http : //mysharepointwork.blogspot.com/2009/10/sharepoint-web-services-get-choice.html
There is actually another way of getting the values using Xelements 实际上,还有另一种使用Xelements获取值的方法
using (var service = new SharePoint.Services.ListsSoapClient())
{
service.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
var listName = "MyList";
var xelement = service.GetList(listName);
var fieldName = "Category"; //My Field name
XNamespace ns = "http://schemas.microsoft.com/sharepoint/soap/";
var selectedField = xelement.Descendants(ns + "Fields").Elements().Where(x => x.Attribute("Name").Value == fieldName).FirstOrDefault();
if (selectedField != null)
{
var choices = selectedField.Elements(ns + "CHOICES").Elements().Where(x => x.Name == ns + "CHOICE").Select(x => x.Value).ToList();
//Do something with choices
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.