我在sharepoint中有一份员工名单.Employee列表中的一列是名为Organization的查找列.我正在尝试编写一个CAML查询来获取组织值不为空的所有员工.但是,即使组织的价值为空,我也会收到所有项目.这就是我想要的
string querystring = string.empty;
querystring = "<Where><IsNotNull><Field RefName='EmployeeOrganization_x0020_Organization' /></IsNotNull></Where>";
Run Code Online (Sandbox Code Playgroud)
此查询将返回列表中的所有项目.
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();
}
Run Code Online (Sandbox Code Playgroud)
<Query>
<Where>
<IsNotNull>
<FieldRef Name='Project'/>
</IsNotNull>
</Where>
</Query>
Run Code Online (Sandbox Code Playgroud)
正在为我工作.您应该使用U2U CAML查询生成器来使用Designer构建查询.它会自动为您生成所需的CAML表达式.
你能从你的背景中提供更多.您对SPQuery实例的设置是什么?
编辑:
<Field RefName='Project'/>
至
<FieldRef Name='Project'/>
归档时间: |
|
查看次数: |
18617 次 |
最近记录: |