【问题标题】:Caml Query to fetch the items where the Lookup Column value is not nullCaml查询以获取查找列值不为空的项目
【发布时间】:2011-11-26 09:09:10
【问题描述】:

我在 sharepoint 中有一个员工列表。员工列表中的一列是名为组织的查找列。 我正在尝试编写一个 CAML 查询来获取组织值不为空的所有员工。但是,即使组织的值为空,我也会收到所有项目。 这就是我正在尝试的

           string querystring = string.empty;
           querystring = "<Where><IsNotNull><Field RefName='EmployeeOrganization_x0020_Organization' /></IsNotNull></Where>";

此查询返回列表中的所有项目。

SPQuery query = new SPQuery();
query.Query = "<Where><IsNotNull><FieldRef Name='EmployeeOrganization_x0020_Organization'/></IsNotNull></Where>";
DataTable dtemp = emplist.GetItems(query).GetDataTable();
  if (dtemp != null)
            {
               GridView1.DataSource = dtemp ;
                GridView1.DataBind();
            }

【问题讨论】:

    标签: sharepoint


    【解决方案1】:
    <Query>
      <Where>
        <IsNotNull>
           <FieldRef Name='Project'/>
        </IsNotNull>
      </Where>
    </Query>
    

    正在为我工​​作。您应该使用 U2U CAML 查询生成器通过 Designer 构建查询。它会自动为您生成所需的 CAML 表达式。

    您能否根据您的上下文提供更多信息。您对 SPQuery 实例的设置是什么?

    编辑:

    &lt;Field RefName='Project'/&gt;

    &lt;FieldRef Name='Project'/&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 2021-11-03
      • 2018-07-08
      • 2020-10-22
      相关资源
      最近更新 更多