'Microsoft.SharePoint.SPListItem' 不包含定义
'Microsoft.SharePoint.SPListItem' does not contain a definition for
'Microsoft.SharePoint.SPListItem' does not contain a definition for
'Image' and no extension method 'Image' accepting a first argument of
type 'Microsoft.SharePoint.SPListItem' could be found
string[] fields = new string[] { "Title", "Image", "Description", "Content" };
SPListItemCollection collection = SPContext.Current.Site.RootWeb.Lists["FOO"].GetItems(fields);
Response.Write(collection[0].Image);
但 Response.Write(collection[0].Title);
工作正常。
Title
是在 SPListItem
class 上定义的成员。每个 List 都会有一个名为 Title 的字段,除非您通过费力的步骤将其删除,因此它位于基础 object.
要获取自定义属性/字段,您需要使用类似的东西:
Response.Write(collection[0]["Image"]);
'Microsoft.SharePoint.SPListItem' does not contain a definition for 'Image' and no extension method 'Image' accepting a first argument of type 'Microsoft.SharePoint.SPListItem' could be found
string[] fields = new string[] { "Title", "Image", "Description", "Content" };
SPListItemCollection collection = SPContext.Current.Site.RootWeb.Lists["FOO"].GetItems(fields);
Response.Write(collection[0].Image);
但 Response.Write(collection[0].Title);
工作正常。
Title
是在 SPListItem
class 上定义的成员。每个 List 都会有一个名为 Title 的字段,除非您通过费力的步骤将其删除,因此它位于基础 object.
要获取自定义属性/字段,您需要使用类似的东西:
Response.Write(collection[0]["Image"]);