我收到无法找到类型或命名空间名称 'listcolumns'(是否缺少 using 指令或程序集引用?)
I am getting a The type or namespace name 'listcolumns' could not be found (are you missing a using directive or an assembly reference?)
好的,所以我有这段代码一直在抛出上面的错误。我真的很想弄明白。
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Collections.Generic;
using System.Collections;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace VarianceList.WebPart1
{
[ToolboxItemAttribute(false)]
public class WebPart1 : WebPart
{
private class ListColumns
{
public String li_requestDate { get; set; }
public String li_paymentAmount { get; set; }
public String li_payeeName { get; set; }
}
这里是错误开始的地方:
private List<listcolumns> ReadFromList()
{
List<listcolumns> lcList = new List<listcolumns>();
using (SPSite site = new SPSite("http://ServerName"))
{
using (SPWeb web = site.OpenWeb("locationOfWeb"))
{
SPList list = web.Lists["ListName"];
SPListItemCollection SpListColl = list.Items;
foreach (SPListItem item in SpListColl)
{
ListColumns lc = new ListColumns();
if (null != item["Title"])
{
if (!(String.IsNullOrEmpty(item["RequestDate"].ToString())))
{
lc.li_requestDate = item["RequestDate"].ToString();
}
// . . . and so forth
另外,我在这里收到以下错误:无法从 'VarianceList.WebPart1.WebPart1.ListColumns' 转换为 'listcolumns'
lcList.Add(lc);
}
}
} // using (SPWeb
} // using (SPSite
return lcList;
} }
}
C# 是一种区分大小写的语言。您定义了 class ListColumns
,但您将其称为 listcolumns
。
那不行。
好的,所以我有这段代码一直在抛出上面的错误。我真的很想弄明白。
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Collections.Generic;
using System.Collections;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace VarianceList.WebPart1
{
[ToolboxItemAttribute(false)]
public class WebPart1 : WebPart
{
private class ListColumns
{
public String li_requestDate { get; set; }
public String li_paymentAmount { get; set; }
public String li_payeeName { get; set; }
}
这里是错误开始的地方:
private List<listcolumns> ReadFromList()
{
List<listcolumns> lcList = new List<listcolumns>();
using (SPSite site = new SPSite("http://ServerName"))
{
using (SPWeb web = site.OpenWeb("locationOfWeb"))
{
SPList list = web.Lists["ListName"];
SPListItemCollection SpListColl = list.Items;
foreach (SPListItem item in SpListColl)
{
ListColumns lc = new ListColumns();
if (null != item["Title"])
{
if (!(String.IsNullOrEmpty(item["RequestDate"].ToString())))
{
lc.li_requestDate = item["RequestDate"].ToString();
}
// . . . and so forth
另外,我在这里收到以下错误:无法从 'VarianceList.WebPart1.WebPart1.ListColumns' 转换为 'listcolumns'
lcList.Add(lc);
}
}
} // using (SPWeb
} // using (SPSite
return lcList;
} }
}
C# 是一种区分大小写的语言。您定义了 class ListColumns
,但您将其称为 listcolumns
。
那不行。