Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.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时出现问题_Sharepoint - Fatal编程技术网

检索富文本框sharepoint时出现问题

检索富文本框sharepoint时出现问题,sharepoint,Sharepoint,我需要从列表中的富文本框中检索值。到目前为止,我的代码如下 ArrayList arCategory=new ArrayList(); SPList myList = myWeb.Lists["PList"]; SPQuery myQuery = new SPQuery(); myQuery.Query = "<OrderBy><FieldRef Name='ProgramID' A

我需要从列表中的富文本框中检索值。到目前为止,我的代码如下

        ArrayList arCategory=new ArrayList();               
        SPList myList = myWeb.Lists["PList"]; 
        SPQuery myQuery = new SPQuery();
        myQuery.Query = "<OrderBy><FieldRef Name='ProgramID' Ascending="False"/></OrderBy>;

            SPListItemCollection myItemCol = myList.GetItems(myQuery);

            foreach (SPListItem myItem in myItemCol)
            {                   
                string strCatTxt = (string)myItem["Category"];-->
ArrayList arCategory=new ArrayList();
SPList myList=myWeb.Lists[“PList”];
SPQuery myQuery=新建SPQuery();
myQuery.Query=“;
SPListItemCollection myItemCol=myList.GetItems(myQuery);
foreach(myItemCol中的SPListItem myItem)
{                   
string strcattext=(string)myItem[“Category”];-->
//类别是多行富文本列

              arCategory.Add(strCatTxt);
            }

           for (int j = 0; j < arCategory.Count; j++)
          {
          Label lblCategory = new Label();
          lblCategory.Text=arCategory[j].Tostring(); ---->Getting exception
          }
arCategory.Add(strcattext);
}
对于(int j=0;j获取异常
}

这里的问题不是SharePoint。在您的代码中,有
lblCategory.Text=arCategory[j].Tostring();

如果
arCategory[j]
null
,则在对其调用ToString()时会出现异常

所以基本上你可以这样修复它:

for (int j = 0; j < arCategory.Count; j++) {
  if (arCategory[j]!=null){
    Label lblCategory = new Label();
    lblCategory.Text=arCategory[j].Tostring(); ---->Getting exception
  }
}
for(int j=0;j获取异常
}
}
编辑: 当然,您也可以在查询中添加
元素,并从类别不同于
null
的项目中只读值。这也将使查询执行得更快