Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 2010 谁能告诉我什么';caml查询代码中有什么错误?_Sharepoint 2010_Sharepoint Designer_Caml_Sharepoint Api - Fatal编程技术网

Sharepoint 2010 谁能告诉我什么';caml查询代码中有什么错误?

Sharepoint 2010 谁能告诉我什么';caml查询代码中有什么错误?,sharepoint-2010,sharepoint-designer,caml,sharepoint-api,Sharepoint 2010,Sharepoint Designer,Caml,Sharepoint Api,查询: <Where> <Eq> <FieldRef Name='Document Type' LookupId='True' /> <Value Type='Text'>Standards(STA)</Value> </Eq> </Where> <OrderBy> <FieldRef Name='Number' Ascending='False

查询:

<Where>
  <Eq>
    <FieldRef Name='Document Type' LookupId='True' />            
    <Value Type='Text'>Standards(STA)</Value>
  </Eq>
</Where>
<OrderBy>
 <FieldRef Name='Number' Ascending='False'/>
</OrderBy>
<RowLimit>1</RowLimit>"

标准(STA)
1"
代码上下文:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Page Language="C#" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register tagprefix="WebPartPages" namespace="Microsoft.SharePoint.WebPartPages" assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register tagprefix="SharePoint" namespace="Microsoft.SharePoint.WebControls" assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<html>

<head>
<meta name="WebPartPageExpansion" content="full" />
<meta name="ProgId" content="SharePoint.WebPartPage.Document" />


<h1>T-Site</h1>

 <script runat="server" type="">            

protected void sevak(object sender, EventArgs e)

string lastitem;
try
{

  using (SPSite objsite = new SPSite("http://..."))
  {
    using (SPWeb objWeb = objSite.OpenWeb())
    {
      SPList objList = objWeb.Lists["...."];
      SPQuery objQuery = new SPQuery();

      objQuery.Query = "<Where><Eq><FieldRef Name='Document Type' LookupId='True' />            <Value Type='Text'>Standards(STA)</Value></Eq></Where><OrderBy><FieldRef Name='Number' Ascending='False'/></OrderBy><RowLimit>1</RowLimit>";

      objQuery.Folder = objList.RootFolder;
      SPListItemCollection colItems = objList.GetItems(objQuery);

      if (colItems.Count>0)
      {
        lastitem=colItems(0);
      }
      else 
      { 
        Label1.Text="noItem";
      }
    }
  }
}
catch (Exception ex)
{
  return ex;
}

Label1.Text= "lastitem";

日本茑屋
受保护的void sevak(对象发送方,事件参数e)
字符串最后一项;
尝试
{
使用(SPSite objsite=新SPSite(“http://..."))
{
使用(SPWeb objWeb=objSite.OpenWeb())
{
SPList objList=objWeb.Lists[“…”];
SPQuery objQuery=新建SPQuery();
objQuery.Query=“标准(STA)1”;
objQuery.Folder=objList.RootFolder;
SPListItemCollection colItems=objList.GetItems(objQuery);
如果(colItems.Count>0)
{
lastitem=colItems(0);
}
其他的
{ 
标签1.Text=“noItem”;
}
}
}
}
捕获(例外情况除外)
{
退换货;
}
Label1.Text=“lastitem”;




我认为问题在于字段引用“文档类型”:

  • FieldRef
    元素需要引用字段的内部名称。如果“文档类型”列是通过UI创建的,则该列的内部名称为“文档类型”

  • 您指定了
    LookupId=“True”
    ,这会导致查找字段的id,但您提供了文本值。根据字段类型,您应该提供文档类型的数字id,或者省略
    LookupId=“True”
    部分以查询查找字段的文本


  • 我认为问题在于字段引用“文档类型”:

  • FieldRef
    元素需要引用字段的内部名称。如果“文档类型”列是通过UI创建的,则该列的内部名称为“文档类型”

  • 您指定了
    LookupId=“True”
    ,这会导致查找字段的id,但您提供了文本值。根据字段类型,您应该提供文档类型的数字id,或者省略
    LookupId=“True”
    部分以查询查找字段的文本

  • <SharePoint:CssLink runat="server"></SharePoint:CssLink>
    <SharePoint:ScriptLink runat="server" language="javascript" name="core.js">
    
    </SharePoint:ScriptLink>
    
    <body>
    
    <form id="form1" runat="server" action="Page-2.aspx">
    <p>
    
    
    <asp:Button runat="server" Text="Submit" id="Button1" OnClick="sevak" ></asp:Button>
    
    
    </p>
    <p><asp:Label runat="server" id="Label1"></asp:Label></p>
    </form>
    </body>
    
    
    </html>