如何在列表中搜索值 [英] how search a value in list

查看:70
本文介绍了如何在列表中搜索值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在sharepoint中有一个列表,有两列(名称(单行文本)和标题(单行文本))

现在我需要获取名称列表玫瑰

但我的代码不起作用并返回总列表



mycode:

 using(ClientContext context = new ClientContext(siteUrl))
{
context.Credentials = new NetworkCredential(bbcNews,564786,mesbahsoft.local);
List oList2 = context.Web.Lists.GetByTitle(Properties.Settings.Default.ListName);


CamlQuery camlQuery2 = new CamlQuery();
camlQuery2.ViewXml =< query > < 其中 > < eq > +
< fieldref name = name < span class =code-attribute> / > < value type = 正文 > Rose< / value > < / eq > < / where > < / query > ;

解决方案

试试这个:



 camlQuery2.ViewXml =< query>< where>< eq>< fieldref name ='name'/>< value type = '文本' >玫瑰及LT; /值GT;< /当量>< /其中>< /查询>中; 


I have a list in sharepoint with two column(name(Single line of text) and title(Single line of text))
Now I need to get a list of title that the name is "Rose"
but My code does not work and returns Total list

mycode:

using (ClientContext context = new ClientContext(siteUrl))
               {
                   context.Credentials = new NetworkCredential("bbcNews", "564786", "mesbahsoft.local");
                   List oList2 = context.Web.Lists.GetByTitle(Properties.Settings.Default.ListName);


                   CamlQuery camlQuery2 = new CamlQuery();
                   camlQuery2.ViewXml = "<query><where> <eq>"+
       " <fieldref name="name" /> <value type="Text">"Rose"</value></eq></where></query>";

解决方案

Try this:

camlQuery2.ViewXml = "<query><where><eq><fieldref name='name'/><value type='Text'>Rose</value></eq></where></query>";


这篇关于如何在列表中搜索值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆